2 * Author: John Tsiombikas <nuclear@member.fsf.org>
4 * This software is public domain. Feel free to use it any way you like.
6 * If public domain is not applicable in your part of the world, you may use
7 * this under the terms of the Creative Commons CC-0 license:
8 * http://creativecommons.org/publicdomain/zero/1.0/
11 * usage example 1: compute the md5 sum of the string "hello world"
13 * struct md5_state md;
15 * md5_msg(&md, "hello world", 11);
18 * md5 sum in: md5_state.sum[0..4]
19 * To print it you may use the helper function md5_sumstr:
20 * printf("%s\n", md5_sumstr(&md));
22 * usage example 2: comput the md5 sum of whatever comes through stdin
25 * struct md5_state md;
29 * while((sz = fread(buf, 1, sizeof buf, stdin)) > 0) {
30 * md5_msg(&md, buf, sz);
34 #ifndef NUCLEAR_DROPCODE_MD5_H_
35 #define NUCLEAR_DROPCODE_MD5_H_
42 unsigned char blockbuf[64];
46 void md5_begin(struct md5_state *md);
47 void md5_msg(struct md5_state *md, void *msg, int msg_size);
48 void md5_end(struct md5_state *md);
50 /* after computing the md5 sum, you may use this function to get a pointer
51 * to a canonical string representation of the sum (identical to GNU md5sum)
53 const char *md5_sumstr(struct md5_state *md);
55 #endif /* NUCLEAR_DROPCODE_MD5_H_ */