[plt-scheme] Message digests: md5, sha1, etc.

From: Jacob Matthews (jacobm at cs.uchicago.edu)
Date: Mon Feb 5 13:29:57 EST 2007

On my aging PowerPC-based PowerBook running OSX:

Welcome to MzScheme v369.6 [3m], Copyright (c) 2004-2007 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")))
> (time (md5 b))
cpu time: 129 real time: 199 gc time: 0
"311175294563b07db7ea80dee2e5b3c6"
> (time (mz:md5 b))
cpu time: 25213 real time: 29283 gc time: 29
#"311175294563b07db7ea80dee2e5b3c6"

On 2/5/07, Jens Axel Søgaard <jensaxel at soegaard.net> 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"
>
>
> --
> Jens Axel Søgaard
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>


Posted on the users mailing list.