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

Safe HaskellSafe-Infered

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

data MD5Context Source

The type for final results.

data MD5Digest Source

After finalizing a context, using md5Finalize, a new type is returned to prevent 're-finalizing' the structure.

Static data

md5InitialContext :: MD5ContextSource

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

Functions

md5 :: ByteString -> MD5DigestSource

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

md5Update :: MD5Context -> ByteString -> MD5ContextSource

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

Closes an MD5 context, thus producing the digest.

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

Methods

outputLength

Arguments

:: Tagged d BitLength

The size of the digest when encoded

blockLength

Arguments

:: Tagged d BitLength

The amount of data operated on in each round of the digest computation

initialCtx

Arguments

:: ctx

An initial context, provided with the first call to updateCtx

updateCtx

Arguments

:: ctx 
-> ByteString 
-> ctx

Used to update a context, repeatedly called until all data is exhausted must operate correctly for imputs of n*blockLength bytes for n elem [0..]

finalize

Arguments

:: ctx 
-> ByteString 
-> d

Finializing a context, plus any message data less than the block size, into a digest