4 Libucw contains two cryptographic hash algorithms: MD5 (RFC 1321) and SHA1 (RFC
5 3174). A SHA1-HMAC (RFC 2104) message authentication is available.
7 There are non-cryptographic hashes as well.
14 - <<sha1:sha1_hmac(),SHA1_HMAC>>
15 - <<usage,Common usage>>
17 Non-cryptographic ones
18 ----------------------
20 - <<strhash,String & block hashes>>
21 - <<inthash,Integer hashes>>
37 There are two ways you can use the hashing routines.
39 - Single-shot interface. If you have an in-memory buffer of the whole
40 message you want to hash, you can use this.
42 char *message = "Hello world";
43 byte output[MD5_SIZE];
44 md5_hash_buffer(output, message, strlen(message));
46 - Multi-shot interface. If you have the message scattered in many
47 buffers or you get it by parts, you do not need to concatenate the
50 byte buffer[MAX_BUFFER];
54 while(buffer_len = get_chunk(buffer, MAX_BUFFER)) {
55 md5_update(&c, buffer, buffer_len);
57 byte output[MD5_SIZE];
58 memcpy(output, md5_final(&c), MD5_SIZE);
60 SHA1 has the same interface, so the same two ways apply.
62 See also <<string:mem_to_hex()>>.