4 Libucw contains two cryptographic hash algorithms: MD5 (RFC 1321) and SHA1 (RFC
9 - <<usage,Common usage>>
25 There are two ways you can use the hashing routines.
27 - Single-shot interface. If you have an in-memory buffer of the whole
28 message you want to hash, you can use this.
30 char *message = "Hello world";
31 byte output[MD5_SIZE];
32 md5_hash_buffer(output, message, strlen(message));
34 - Multi-shot interface. If you have the message scattered in many
35 buffers or you get it by parts, you do not need to concatenate the
38 byte buffer[MAX_BUFFER];
42 while(buffer_len = get_chunk(buffer, MAX_BUFFER)) {
43 md5_update(&c, buffer, buffer_len);
45 byte output[MD5_SIZE];
46 memcpy(output, md5_final(&c), MD5_SIZE);
48 SHA1 has the same interface, so the same two ways apply.
50 See also <<string:mem_to_hex()>>.