H49339 s 00117/00000/00000 d D 1.1 98/05/25 09:24:57 orc 2 1 c New html manpage for md5lib cC cK24531 cZ-00:00 e s 00000/00000/00000 d D 1.0 70/01/01 03:09:62 BK 1 0 c RCS to BitKeeper cBorc@india.pell.portland.or.us|ChangeSet|20000922002442|17918|777fbc9d629e3be4 cK00042 cPbasis/doc/md5.html cO-rw-rw-r-- cR66a28790706d5485 cT cV4 cX0x23 e u U f e 0 f x 0x23 t T I 2
md5lib is a set of routines that let you generate md5 digital signatures for various things. It's set up somewhat like stdio -- you open a md5 connection, write data to it, then close it and are handed back a signature.
To generate a digital signature for whatever's on stdin:
/* * compile with cc -o md5 md5.c -lbasis */ #include <stdio.h> #include <md5lib.h> main() { JH handle; char bfr[512]; unsigned char *sig; int siz, ix; if ((handle = md5_init()) == 0) { perror("md5_init"); exit(1); } while ((siz = read(fileno(0), bfr, sizeof bfr)) > 0) md5_put(bfr, siz, handle); sig = md5_finish(handle, 0); for (ix = 0; ix < 16; ix++) printf("%02x", sig[ix]); putchar('\n'); }
There is a woeful lack of error checking. If you pass a bogus JH into md5_put or md5_finish, the function will most crash your program.
md5lib will silently return incorrect signatures for objects larger than 2^29 bytes (approximately 550 megabytes.)
None. This code is in the public domain, and you may do with it as you wish.
This code is written from the specification in RFC1321; it does not include code from the sample implementation there, or from any other source.
JH stands for John Hancock
orc@pell.chi.il.us (David Parsons). E 2 I 1 E 1