License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | unknown |
Safe Haskell | Trustworthy |
Language | Haskell98 |
Crypto.Hash
Description
Crypto hash main module
- class HashAlgorithm a where
- hashInit :: Context a
- hashUpdates :: Context a -> [ByteString] -> Context a
- hashFinalize :: Context a -> Digest a
- digestFromByteString :: ByteString -> Maybe (Digest a)
- type HashFunctionBS a = ByteString -> Digest a
- type HashFunctionLBS a = ByteString -> Digest a
- data Context a
- data Digest a
- digestToByteString :: Digest a -> ByteString
- digestToHexByteString :: Digest a -> ByteString
- hash :: HashAlgorithm a => ByteString -> Digest a
- hashlazy :: HashAlgorithm a => ByteString -> Digest a
- hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context a
- data MD2
- data MD4
- data MD5
- data SHA1
- data SHA224
- data SHA256
- data SHA384
- data SHA512
- data RIPEMD160
- data Tiger
- data SHA3_224
- data SHA3_256
- data SHA3_384
- data SHA3_512
- data Skein256_224
- data Skein256_256
- data Skein512_224
- data Skein512_256
- data Skein512_384
- data Skein512_512
- data Whirlpool
- data HMAC a = HMAC {}
- hmac :: HashFunctionBS a -> Int -> ByteString -> ByteString -> HMAC a
Types
class HashAlgorithm a where
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
Initialize a new context for this hash algorithm
hashUpdates :: Context a -> [ByteString] -> Context a
Update the context with a list of strict bytestring, and return a new context with the updates.
hashFinalize :: Context a -> Digest a
Finalize a context and return a digest.
digestFromByteString :: ByteString -> Maybe (Digest a)
Try to convert a binary digest bytestring to a digest.
Instances
type HashFunctionBS a = ByteString -> Digest a
Alias to a single pass hash function that operate on a strict bytestring
type HashFunctionLBS a = ByteString -> Digest a
Alias to a single pass hash function that operate on a lazy bytestring
data Context a
Represent a context for a given hash algorithm.
data Digest a
Represent a digest for a given hash algorithm.
Functions
digestToByteString :: Digest a -> ByteString
Return the binary digest
digestToHexByteString :: Digest a -> ByteString
Return the hexadecimal (base16) bytestring of the digest
hash :: HashAlgorithm a => ByteString -> Digest a
Hash a strict bytestring into a digest.
hashlazy :: HashAlgorithm a => ByteString -> Digest a
Hash a lazy bytestring into a digest.
hashUpdate :: HashAlgorithm a => Context a -> ByteString -> Context a
run hashUpdates on one single bytestring and return the updated context.
hash algorithms
data MD2
Instances
data MD4
Instances
data MD5
Instances
data SHA1
Instances
data SHA224
Instances
data SHA256
Instances
data SHA384
Instances
data SHA512
Instances
data RIPEMD160
Instances
data Tiger
Instances
data SHA3_224
Instances
data SHA3_256
Instances
data SHA3_384
Instances
data SHA3_512
Instances
data Skein256_224
Instances
data Skein256_256
Instances
data Skein512_224
Instances
data Skein512_256
Instances
data Skein512_384
Instances
data Skein512_512
Instances
data Whirlpool
Instances
MAC algorithms
data HMAC a
Represent an HMAC that is phantom types with the hash used to produce the mac.
The Eq instance is constant time.
Constructors
HMAC | |
Fields
|
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