4 LibUCW contains implementations of several hash algorithms.
6 <<crypto,Cryptographic hashes>>:
8 - <<md5,MD5>> (RFC 1321)
9 - <<sha1,SHA1>> (RFC 3174)
10 - <<hash:sha1_hmac(),SHA1_HMAC message authentication>> (RFC 2104)
11 - <<usage,Common usage>>
13 <<checksum,Checksums>>:
15 - <<crypto:adler,Adler-32>>
18 <<nocrypto,Non-cryptographic hashes>>:
20 - <<strhash,String & block hashes>>
21 - <<inthash,Integer hashes>>
41 There are two ways you can use the hashing routines.
43 - Single-shot interface. If you have an in-memory buffer of the whole
44 message you want to hash, you can use this.
46 char *message = "Hello world";
47 byte output[MD5_SIZE];
48 md5_hash_buffer(output, message, strlen(message));
50 - Multi-shot interface. If you have the message scattered in many
51 buffers or you get it by parts, you do not need to concatenate the
54 byte buffer[MAX_BUFFER];
58 while(buffer_len = get_chunk(buffer, MAX_BUFFER)) {
59 md5_update(&c, buffer, buffer_len);
61 byte output[MD5_SIZE];
62 memcpy(output, md5_final(&c), MD5_SIZE);
64 SHA1 has the same interface, so the same two ways apply.
66 See also <<string:mem_to_hex()>>.
72 Their purpose is checking against random data changes, hardware
73 failures and alike. They are not to be used against aimed attacks.
78 The <<compress:adler,Adler-32 checksum>> is documented in the
79 <<compress:,compression capter>>.
84 32-bit Cyclic Redundancy Check with the polynomial suggested by
85 Castagnoli et al.: Optimization of Cyclic Redundancy-Check Codes
86 with 24 and 32 Parity Bits", IEEE Trans. on Communications, Vol. 41,
89 The interface is similar to the one we use for the cryptographic hashes.
94 Non-cryptographic hashes
95 ------------------------
97 They are usually used to identify values in hash tables.
99 All these functions expect to be moduled by the size of a hash table.
100 The size should be a prime number (it gives better distribution).