2 * UCW Library -- MD5 Message Digest
4 * This file is in public domain (see ucw/md5.c).
11 * Internal MD5 hash state.
12 * You should use it just as an opaque handle only.
20 void md5_init(md5_context *context); /** Initialize the MD5 hashing algorithm in @context. **/
22 * Push another @len bytes of data from @buf to the MD5 hash
23 * represented by @context. You can call it multiple time on the same
24 * @context without reinitializing it and the result will be the same
25 * as if you concatenated all the data together and fed them here all at
28 void md5_update(md5_context *context, const byte *buf, uns len);
30 * Call this after the last @md5_update(). It will terminate the
31 * algorithm and return a pointer to the result.
33 * Note that the data it points to are stored inside the @context, so
34 * if you use it to compute another hash or it ceases to exist, the
35 * pointer becomes invalid.
37 * To convert the hash to its usual hexadecimal representation, see
38 * <<string:mem_to_hex()>>.
40 byte *md5_final(md5_context *context);
43 * This is the core routine of the MD5 algorithm. It takes 16 longwords of
44 * data in @in and transforms the hash in @buf according to them.
46 * You probably do not want to call this one directly.
48 void md5_transform(u32 buf[4], const u32 in[16]);
51 * MD5 one-shot convenience method. It takes @length bytes from
52 * @buffer, creates the hash from them and returns it in @output.
54 * It is equivalent to this code:
58 * md5_update(&c, buffer, length);
59 * memcpy(outbuf, md5_final(&c), MD5_SIZE);
61 void md5_hash_buffer(byte *outbuf, const byte *buffer, uns length);
63 #define MD5_HEX_SIZE 33 /** How many bytes a string buffer for MD5 in hexadecimal format should have. **/
64 #define MD5_SIZE 16 /** Number of bytes the MD5 hash takes in the binary form. **/
66 #endif /* !_UCW_MD5_H */