[plt-scheme] MD5 in v299.400
On Oct 21, 2005, at 7:57 AM, Jens Axel Søgaard wrote:
> 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".
>
Yes. That's it.
>> 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 consisting
> 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.
>
Ok, yes, I assumed it had something to do with that. But my question
is still not answered. If the scheme code in "collects/mzlib/md5.ss"
uses strings, why does the the md5 function provided by (require (lib
"md5.ss")) require bytes?
>> 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 #"")
> #"d41d8cd98f00b204e9800998ecf8427e")
> (equal? (md5 #"a")
> #"0cc175b9c0f1b6a831c399e269772661")
> (equal? (md5 #"abc")
> #"900150983cd24fb0d6963f7d28e17f72")
> (equal? (md5 #"message digest")
> #"f96b697d7cb7938d525a2f31aaf161d0")
> (equal? (md5 #"abcdefghijklmnopqrstuvwxyz")
> #"c3fcd3d76192e4007dfb496cca67e13b")
> (equal? (md5
> #"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
> #"d174ab98d277d9f5a5611c2c9f419d9f")
> (equal? (md5
> #"12345678901234567890123456789012345678901234567890123456789012345678
> 901234567890")
> #"57edf4a22be3c955ac49da2e2107b67a"))
> 'passed
> 'failed))
> > (md5-test)
> passed
>
> The PLT test-suite contains the following test:
>
> <http://pre.plt-scheme.org/plt/collects/tests/mzscheme/md5.ss>
>
Yes, thanks. I understand that will work. But again, why is the
source code in collects/mzlib/md5.ss, which clearly requires strings,
actually evaluating to a procedure that requires byte-strings? The
only thing I can imagine is that there is some sort of devilish
syntax-manipulation going on in a hidden level that I'm not aware of,
which is somehow magically converting string functionality to byte
functionality.
Yet I doubt this is possible, so I must therefore assume that the
scheme code in collects/mzlib/md5.ss is not actually producing the
md5 procedure yielded by (require (lib "md5.ss")). But if that is
the case, where is the true source code located? And why is 'bogus',
misleading, 'dead' library source code being distributed with PLT-
Scheme?
- dr