cryptohash-0.8.3: collection of crypto hashes, fast, pure and practical

Portabilityunknown
Stabilityexperimental
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellTrustworthy

Crypto.Hash

Contents

Description

Crypto hash main module

Synopsis

Types

class HashAlgorithm a whereSource

Class representing hashing algorithms.

The hash algorithm is built over 3 primitives:

init : create a new context updates : update the context with some strict bytestrings finalize : finalize the context into a digest

Methods

hashInit :: Context aSource

Initialize a new context for this hash algorithm

hashUpdates :: Context a -> [ByteString] -> Context aSource

Update the context with a list of strict bytestring, and return a new context with the updates.

hashFinalize :: Context a -> Digest aSource

Finalize a context and return a digest.

digestFromByteString :: ByteString -> Maybe (Digest a)Source

Try to convert a binary digest bytestring to a digest.

type HashFunctionBS a = ByteString -> Digest aSource

Alias to a single pass hash function that operate on a strict bytestring

type HashFunctionLBS a = ByteString -> Digest aSource

Alias to a single pass hash function that operate on a lazy bytestring

data Context a Source

Represent a context for a given hash algorithm.

data Digest a Source

Represent a digest for a given hash algorithm.

Instances

Eq (Digest a) 
Eq (Digest a) => Ord (Digest a) 
Show (Digest a) 

Functions

digestToByteString :: Digest a -> ByteStringSource

Return the binary digest

digestToHexByteString :: Digest a -> ByteStringSource

Return the hexadecimal (base16) bytestring of the digest

hash :: HashAlgorithm a => ByteString -> Digest aSource

Hash a strict bytestring into a digest.

hashlazy :: HashAlgorithm a => ByteString -> Digest aSource

Hash a lazy bytestring into a digest.

hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context aSource

run hashUpdates on one single bytestring and return the updated context.

hash algorithms

data MD2 Source

Instances

data MD4 Source

Instances

data MD5 Source

Instances

data SHA1 Source

Instances

MAC algorithms

data HMAC a Source

Represent an HMAC that is phantom types with the hash used to produce the mac.

The Eq instance is constant time.

Constructors

HMAC 

Fields

hmacToByteString :: ByteString

return the binary HMAC

Instances

Eq (HMAC a) 

hmacSource

Arguments

:: HashFunctionBS a

Hash function to use

-> Int

Block size in bytes of the hash function

-> ByteString

Secret key

-> ByteString

Message to MAC

-> HMAC a 

compute a MAC using the supplied hashing function