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

From: Paulo J. Matos (pocm at soton.ac.uk)
Date: Tue Feb 6 10:57:01 EST 2007

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"
>

Works on Gentoo Linux.
Here's output for your brief tests on my Intel DuoCore:
Welcome to DrScheme, version 369.7-svn30jan2007 [3m].
Language: Pretty Big (includes MrEd and Advanced Student).
> (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: 16 real time: 15 gc time: 0
"311175294563b07db7ea80dee2e5b3c6"
> (time (mz:md5 b))
cpu time: 14861 real time: 14877 gc time: 0
#"311175294563b07db7ea80dee2e5b3c6"
>

Thanks for this fine addition.

Cheers,

Paulo Matos

>
> --
> Jens Axel Søgaard
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
>
>


-- 
Paulo Jorge Matos - pocm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm
PhD Student @ ECS
University of Southampton, UK


Posted on the users mailing list.