cryptonite-0.10: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.Hash

Contents

- Types
- Functions
- hash methods parametrized by algorithm
- hash methods
- Hash algorithms

Description

Generalized cryptographic hash interface, that you can use with cryptographic hash algorithm that belong to the HashAlgorithm type class.

    import Crypto.Hash

    sha1 :: ByteString -> Digest SHA1
    sha1 = hash

    hexSha3_512 :: ByteString -> String
    hexSha3_512 bs = show (hash bs :: Digest SHA3_512)

Synopsis

- data Context a
- data Digest a
- digestFromByteString :: (HashAlgorithm a, ByteArrayAccess ba) => ba -> Maybe (Digest a)
- hashInitWith :: HashAlgorithm alg => alg -> Context alg
- hashWith :: (ByteArrayAccess ba, HashAlgorithm alg) => alg -> ba -> Digest alg
- hashInit :: HashAlgorithm a => Context a
- hashUpdates :: (HashAlgorithm a, ByteArrayAccess ba) => Context a -> [ba] -> Context a
- hashUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => Context a -> ba -> Context a
- hashFinalize :: HashAlgorithm a => Context a -> Digest a
- hash :: (ByteArrayAccess ba, HashAlgorithm a) => ba -> Digest a
- hashlazy :: HashAlgorithm a => ByteString -> Digest a
- module Crypto.Hash.Algorithms

# Types

data Context a Source

Represent a context for a given hash algorithm.

Instances

NFData (Context a) Source |
ByteArrayAccess (Context a) Source |

data Digest a Source

Represent a digest for a given hash algorithm.

Instances

Eq (Digest a) Source |
Ord (Digest a) Source |
Show (Digest a) Source |
NFData (Digest a) Source |
ByteArrayAccess (Digest a) Source |

# Functions

digestFromByteString :: (HashAlgorithm a, ByteArrayAccess ba) => ba -> Maybe (Digest a) Source

Try to transform a bytearray into a Digest of specific algorithm.

If the digest is not the right size for the algorithm specified, then Nothing is returned.

# hash methods parametrized by algorithm

hashInitWith :: HashAlgorithm alg => alg -> Context alg Source

Initialize a new context for a specified hash algorithm

hashWith :: (ByteArrayAccess ba, HashAlgorithm alg) => alg -> ba -> Digest alg Source

Run the `hash` function but takes an explicit hash algorithm parameter

# hash methods

hashInit :: HashAlgorithm a => Context a Source

Initialize a new context for this hash algorithm

hashUpdates :: (HashAlgorithm a, ByteArrayAccess ba) => Context a -> [ba] -> Context a Source

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

hashUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => Context a -> ba -> Context a Source

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

hashFinalize :: HashAlgorithm a => Context a -> Digest a Source

Finalize a context and return a digest.

hash :: (ByteArrayAccess ba, HashAlgorithm a) => ba -> Digest a Source

Hash a strict bytestring into a digest.

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

Hash a lazy bytestring into a digest.

# Hash algorithms

module Crypto.Hash.Algorithms