[plt-scheme] Message digests: md5, sha1, etc.
$ uname -a
Linux dynamo 2.6.16-gentoo-r7 #10 Tue Jun 27 20:26:34 EDT 2006 x86_64
AMD Athlon(tm) 64 Processor 3500+ AuthenticAMD GNU/Linux
~ $ mzscheme
Welcome to MzScheme version 360, Copyright (c) 2004-2006 PLT Scheme Inc.
> (require (planet "digest.ss" ("soegaard" "digest.plt" 1 0)))
> (digest #"abc" 'md5)
"900150983cd24fb0d6963f7d28e17f72"
> (digest #"abc" 'sha1)
"a9993e364706816aba3e25717850c26c9cd0d89d"
> (define b (make-bytes 10000000))
> (md5 b)
"311175294563b07db7ea80dee2e5b3c6"
> (require (prefix mz: (lib "md5.ss")))
> (mz:md5 b)
#"311175294563b07db7ea80dee2e5b3c6"
> (time (md5 b))
cpu time: 36 real time: 38 gc time: 0
"311175294563b07db7ea80dee2e5b3c6"
> (time (mz:md5 b))
cpu time: 12053 real time: 12216 gc time: 0
#"311175294563b07db7ea80dee2e5b3c6"
> (time (md5 b))
cpu time: 40 real time: 41 gc time: 0
"311175294563b07db7ea80dee2e5b3c6"
> (time (mz:md5 b))
cpu time: 12065 real time: 12330 gc time: 36
#"311175294563b07db7ea80dee2e5b3c6"
>
Jens Axel Søgaard wrote:
> Hi all,
>
> Fresh of the press is set of bindings for the message digest
> algorithms of libcrypto:
>
> <http://planet.plt-scheme.org/300/docs/soegaard/digest.plt/1/0/doc.txt>
>
> I have tested it on Windows, so I'd appreciate if a kind soul can
> tell me, whether it works on OS X or Linux too. It ought to, but ...
>
> Example:
>
> > (require (planet "digest.ss" ("soegaard" "digest.plt" 1 0)))
> > (digest #"abc" 'md5)
> "900150983cd24fb0d6963f7d28e17f72"
> > (digest #"abc" 'sha1)
> "a9993e364706816aba3e25717850c26c9cd0d89d"
>
>
> Note that the libcrypto md5 is somewhat faster than (lib "md5.ss"):
>
> > (define b (make-bytes 10000000))
> > (md5 b)
> "311175294563b07db7ea80dee2e5b3c6"
> > (require (prefix mz: (lib "md5.ss")))
> > (mz:md5 b)
> #"311175294563b07db7ea80dee2e5b3c6"
> > (time (md5 b))
> cpu time: 16 real time: 15 gc time: 0
> "311175294563b07db7ea80dee2e5b3c6"
> > (time (mz:md5 b))
> cpu time: 14734 real time: 15079 gc time: 0
> #"311175294563b07db7ea80dee2e5b3c6"
>
>