NAME sha - old Secure Hash Algorithm (SHS FIPS Pub 180) SYNOPSIS sha([arg1 [, val ...]]) TYPES arg1 any val any return HASH or number DESCRIPTION The sha() builtin implements the old Secure Hash Algorithm (SHA). The SHA is sometimes referenced as SHS. The SHA is a 160 bit hash. With no args, sha() returns the default initial SHA-1 HASH state. If arg1 is a HASH state and no other val args are given, then the HASH state is finalized and the numeric value of the hash is given. If arg1 is a HASH state and one or more val args are given, then the val args are used to modify the arg1 HASH state. The new arg1 HASH state is returned. If arg1 is not a a HASH state, then the initial HASH is used and modifed by arg1 and any val args supplied. The return value is the new HASH state. The following table gives a summary of actions and return values. Here, assume that 'h' is a HASH state: sha() HASH returns initial HASH state sha(h) number h is put into final form and the numeric value of the hash state sha(x) HASH modify the initial state by hashing 'x' sha(sha(), x) HASH the same as sha(x) sha(x, y) HASH the same as sha(sha(x), y) sha(h, x, y) HASH modify state 'h' by 'x' and then 'y' sha(sha(h,x,y)) number numeric value of the above call EXAMPLE > base(16) 0xa > sha() sha hash state > sha(sha()) 0xf96cea198ad1dd5617ac084a3d92c6107708c0ef > sha("x", "y", "z") == sha("xyz") 1 > sha("x", "y", "z") == sha("xy") 0 > sha(sha("this is", 7^19-8, "a composit", 3i+4.5, "hash")) 0x21e42319a26787046c2b28b7ae70f1b54bf0ba2a > x = sha(list(1,2,3), "curds and whey", 2^21701-1, pi()) > x sha hash state > sha(x) 0xc9e155522ea4a38d85340e6f1c2e36636950ea7e > y = sha() > y = sha(y, list(1,2,3), "curds and whey") > y = sha(y, 2^21701-1) > y = sha(y, pi()) > y sha hash state > sha(y) 0xc9e155522ea4a38d85340e6f1c2e36636950ea7e LIMITS none LIBRARY HASH* hash_init(int, HASH*); void hash_free(HASH*); HASH* hash_copy(HASH*); int hash_cmp(HASH*, HASH*); void hash_print(HASH*); ZVALUE hash_final(HASH*); HASH* hash_long(int, long, HASH*); HASH* hash_zvalue(int, ZVALUE, HASH*); HASH* hash_number(int, void*, HASH*); HASH* hash_complex(int, void*, HASH*); HASH* hash_str(int, char*, HASH*); HASH* hash_usb8(int, USB8*, int, HASH*); HASH* hash_value(int, void*, HASH*); SEE ALSO ishash, sha1