I've written a set of bindings for the MD5 routines provided by
RSA. I've taken the C code included in the FreeBSD distribution.
My interface currently looks as follows:
The low-level procedures work on a "context":
(make-md5-context) -> md5-context
(md5-context? obj) -> boolean
(init-md5-context! md5-context) -> unspecific
(update-md5-context! md5-context string) -> unspecific
(pad-md5-context! md5-context) -> unspecific
To obtain the actual result of the algorithm, the next procedure turns
a md5-context into a md5-digit:
(md5-context->md5-digest md5-context) -> md5-digit
Two pairs of procedures exist to convert a md5-digit to external
representations and back:
(md5-digest->number md5-digest) -> number
(md5-digest->string md5-digest) -> string
(string->md5-digest string) -> md5-digest
(number->md5-digest number) -> md5-digest
The following high-level procedures compute digests for strings and
ports:
(md5-digest-for-string string) -> md5-digest
(md5-digest-for-string port [buffersize]) -> md5-digest
The port-reading loop in port->md5-digest is written in Scheme; it
takes about 0.10 seconds for a 2MB file on a 600MHz Athlon.
Comments? Suggestions? Anybody alive?
--
Martin
|