Initial revision
[LeanCalc.git] / help / sha1
1 NAME
2     sha1 - Secure Hash Algorithm (SHS-1 FIPS Pub 180-1)
3
4 SYNOPSIS
5     sha1([arg1 [, val ...]])
6
7 TYPES
8     arg1        any
9     val         any
10
11     return      HASH or number
12
13 DESCRIPTION
14     The sha1() builtin implements the old Secure Hash Algorithm
15     (SHA).  The SHA is sometimes referenced as SHS.  The SHA
16     is a 160 bit hash.
17
18     With no args, sha1() returns the default initial SHA-1 HASH state.
19
20     If arg1 is a HASH state and no other val args are given, then the
21     HASH state is finalized and the numeric value of the hash is given.
22
23     If arg1 is a HASH state and one or more val args are given,
24     then the val args are used to modify the arg1 HASH state.
25     The new arg1 HASH state is returned.
26
27     If arg1 is not a a HASH state, then the initial HASH is
28     used and modifed by arg1 and any val args supplied.  The
29     return value is the new HASH state.
30
31     The following table gives a summary of actions and return values.
32     Here, assume that 'h' is a HASH state:
33
34         sha1()                  HASH    returns initial HASH state
35
36         sha1(h)                 number  h is put into final form and the
37                                         numeric value of the hash state
38
39         sha1(x)                 HASH    modify the initial state by hashing 'x'
40
41         sha1(sha1(), x)         HASH    the same as sha1(x)
42
43         sha1(x, y)              HASH    the same as sha1(sha1(x), y)
44
45         sha1(h, x, y)           HASH    modify state 'h' by 'x' and then 'y'
46
47         sha1(sha1(h,x,y))       number  numeric value of the above call
48
49 EXAMPLE
50     > base(16)
51             0xa
52
53     > sha1()
54             sha1 hash state
55     > sha1(sha1())
56             0xda39a3ee5e6b4b0d3255bfef95601890afd80709
57
58     > sha1("x", "y", "z") == sha1("xyz")
59             1
60     > sha1("x", "y", "z") == sha1("xy")
61             0
62
63     > sha1(sha1("this is", 7^19-8, "a composit", 3i+4.5, "hash"))
64             0xc3e1b562bf45b3bcfc055ac65b5b39cdeb6a6c55
65
66     > x = sha1(list(1,2,3), "curds and whey", 2^21701-1, pi())
67     > x
68             sha1 hash state
69     > sha1(x)
70             0x988d2de4584b7536aa9a50a5749707a37affa1b5
71
72     > y = sha1()
73     > y = sha1(y, list(1,2,3), "curds and whey")
74     > y = sha1(y, 2^21701-1)
75     > y = sha1(y, pi())
76     > y
77             sha1 hash state
78     > sha1(y)
79             0x988d2de4584b7536aa9a50a5749707a37affa1b5
80
81 LIMITS
82     none
83
84 LINK LIBRARY
85     HASH* hash_init(int, HASH*);
86     void hash_free(HASH*);
87     HASH* hash_copy(HASH*);
88     int hash_cmp(HASH*, HASH*);
89     void hash_print(HASH*);
90     ZVALUE hash_final(HASH*);
91     HASH* hash_long(int, long, HASH*);
92     HASH* hash_zvalue(int, ZVALUE, HASH*);
93     HASH* hash_number(int, void*, HASH*);
94     HASH* hash_complex(int, void*, HASH*);
95     HASH* hash_str(int, char*, HASH*);
96     HASH* hash_usb8(int, USB8*, int, HASH*);
97     HASH* hash_value(int, void*, HASH*);
98
99 SEE ALSO
100     ishash, sha
101