[Haskell] Fingerprints and hashing

Neil Mitchell ndmitchell at gmail.com
Thu Oct 11 06:18:52 EDT 2007

Hi Simon,

> We are all familiar with the idea of an MD5 checksum, which provides a reliable "fingerprint" for a file, usually 128 bits or so.  If the file changes, the fingerprint is (almost) certain to do so too.  There are lots of techniques: CRC, shar?, MD5, etc.

I believe the basic operations are all in the Crypto library:
- see Data.Digest.SHA1 and Data.Digest.MD5 - digest is simply another
word for fingerprint in this sense.

However, your fingerprint stuff sounds a lot more like a request for a
Hash function - rather than something that operates over streams of
bytes. To get both, I'd recommend something like taking the digest of
the data after calling show, or after serialising it to a ByteString
with the binary library. Doing it this way means you have no
additional need for a FingerPrint class but can reuse the existing
Show/Binary class.



More information about the Haskell mailing list