| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Crypto.Sodium.Hash
Description
Hashing.
It is best to import this module qualified:
import qualified Crypto.Sodium.Hash as Hash hash_blake2b256_keyed = Hash.blake2bWithKey@32 key message hash_blake2b256 = Hash.blake2b@32 message hash_blake2b512 = Hash.blake2b@64 message hash_sha256 = Hash.sha256message hash_sha512 = Hash.sha512message
Synopsis
- type HashBlake2b len a = SizedByteArray len a
- blake2b :: forall len hashBytes pt. (ByteArrayAccess pt, ByteArray hashBytes, KnownNat len, CRYPTO_GENERICHASH_BYTES_MIN <= len, len <= CRYPTO_GENERICHASH_BYTES_MAX) => pt -> HashBlake2b len hashBytes
- blake2bWithKey :: forall len hashBytes pt key. (ByteArrayAccess pt, ByteArrayAccess key, ByteArray hashBytes, KnownNat len, CRYPTO_GENERICHASH_BYTES_MIN <= len, len <= CRYPTO_GENERICHASH_BYTES_MAX) => key -> pt -> HashBlake2b len hashBytes
- type HashSha256 a = SizedByteArray CRYPTO_HASH_SHA256_BYTES a
- sha256 :: (ByteArrayAccess pt, ByteArray hashBytes) => pt -> HashSha256 hashBytes
- type HashSha512 a = SizedByteArray CRYPTO_HASH_SHA512_BYTES a
- sha512 :: (ByteArrayAccess pt, ByteArray hashBytes) => pt -> HashSha512 hashBytes
BLAKE2b
type HashBlake2b len a = SizedByteArray len a Source #
Hash returned by blake2b.
This type is parametrised by hash size in bytes and the actual data type
that contains bytes. This can be, for example, a ByteString.
Length must be between 16 and 64 bytes.
Arguments
| :: forall len hashBytes pt. (ByteArrayAccess pt, ByteArray hashBytes, KnownNat len, CRYPTO_GENERICHASH_BYTES_MIN <= len, len <= CRYPTO_GENERICHASH_BYTES_MAX) | |
| => pt | Message to hash |
| -> HashBlake2b len hashBytes |
Arguments
| :: forall len hashBytes pt key. (ByteArrayAccess pt, ByteArrayAccess key, ByteArray hashBytes, KnownNat len, CRYPTO_GENERICHASH_BYTES_MIN <= len, len <= CRYPTO_GENERICHASH_BYTES_MAX) | |
| => key | Hash key |
| -> pt | Message to hash |
| -> HashBlake2b len hashBytes |
Hash a message using BLAKE2b with a key.
hash128_keyed = Hash.blake2bWithKey@16 key message hash256_keyed = Hash.blake2bWithKey@32 key message hash512_keyed = Hash.blake2bWithKey@64 key message
keyis the BLAKE2b key.messageis the data you are hashing.
SHA-2
type HashSha256 a = SizedByteArray CRYPTO_HASH_SHA256_BYTES a #
Hash returned by sha256.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString.
Arguments
| :: (ByteArrayAccess pt, ByteArray hashBytes) | |
| => pt | Message to hash |
| -> HashSha256 hashBytes |
type HashSha512 a = SizedByteArray CRYPTO_HASH_SHA512_BYTES a #
Hash returned by sha512.
This type is parametrised by the actual data type that contains
bytes. This can be, for example, a ByteString.
Arguments
| :: (ByteArrayAccess pt, ByteArray hashBytes) | |
| => pt | Message to hash |
| -> HashSha512 hashBytes |