[plt-scheme] MD5 in v299.400

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Fri Oct 21 07:57:06 EDT 2005

David Richards wrote:

> I don't understand the discrepancy between the definition of md5 in  
> md5.ss, and the one which is provided by (require (lib "md5.ss")).

Where is the first the first md5.ss located? The one in (require (lib 
"md5.ss")) is in "collects/mzlib/md5.ss".

> I don't understand why md5 requires a byte-string argument, instead  
> of a string.

That is due to unicode. The md5-algorithm works on good, old strings 
of 8-bit characters. The source of md5.ss keeps mentioning strings, but 
note that
it was written in 2002, before unicode and byte-strings were introduced 
in PLT Scheme.

> The test code in "md5.ss" does not evaluate, because arguments are  
> the wrong type.

The uncommented test is the original one. Here is an updated version:

(define (md5-test)
    (if (and (equal? (md5 #"")
             (equal? (md5 #"a")
             (equal? (md5 #"abc")
             (equal? (md5 #"message digest")
             (equal? (md5 #"abcdefghijklmnopqrstuvwxyz")
             (equal? (md5 
             (equal? (md5 
 > (md5-test)

The PLT test-suite contains the following test:


Jens Axel Søgaard

Posted on the users mailing list.