pureMD5-2.1.3: A Haskell-only implementation of the MD5 digest (hash) algorithm.

Safe HaskellNone
LanguageHaskell2010

Data.Digest.Pure.MD5

Contents

Description

It is suggested you use the 'crypto-api' class-based interface to access the MD5 algorithm. Either rely on type inference or provide an explicit type:

  hashFileStrict = liftM hash' . B.readFile
  hashFileLazyBS = liftM hash . B.readFile

Synopsis

Types

Static data

md5InitialContext :: MD5Context #

The initial context to use when calling md5Update for the first time

Functions

md5 :: ByteString -> MD5Digest #

Processes a lazy ByteString and returns the md5 digest. This is probably what you want.

md5Update :: MD5Context -> ByteString -> MD5Context #

Alters the MD5Context with a partial digest of the data.

The input bytestring MUST be a multiple of the blockSize or bad things can happen (incorrect digest results)!

md5Finalize :: MD5Context -> ByteString -> MD5Digest #

Closes an MD5 context, thus producing the digest.

md5DigestBytes :: MD5Digest -> ByteString #

The raw bytes of an MD5Digest. It is always 16 bytes long.

You can also use the Binary or Serialize instances to output the raw bytes. Alternatively you can use show to prodce the standard hex representation.

Crypto-API interface

class (Serialize d, Eq d, Ord d) => Hash ctx d | d -> ctx, ctx -> d where #

The Hash class is intended as the generic interface targeted by maintainers of Haskell digest implementations. Using this generic interface, higher level functions such as hash and hash' provide a useful API for comsumers of hash implementations.

Any instantiated implementation must handle unaligned data.

Minimum complete definition: outputLength, blockLength, initialCtx, updateCtx, and finalize.

Minimal complete definition

outputLength, blockLength, initialCtx, updateCtx, finalize

Methods

outputLength :: Tagged * d BitLength #

blockLength :: Tagged * d BitLength #

initialCtx :: ctx #

updateCtx :: ctx -> ByteString -> ctx #

finalize :: ctx -> ByteString -> d #

hash :: ByteString -> d #

Hash a lazy ByteString, creating a digest

hash' :: ByteString -> d #

Hash a strict ByteString, creating a digest