crypto-sodium-0.0.5.0: Easy-and-safe-to-use high-level cryptography based on Sodium
Safe HaskellNone
LanguageHaskell2010

Crypto.Sodium.Hash

Contents

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.sha256 message
hash_sha512 = Hash.sha512 message
Synopsis

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.

blake2b Source #

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 

Hash a message using BLAKE2b.

hash128 = Hash.blake2b @16 message
hash256 = Hash.blake2b @32 message
hash512 = Hash.blake2b @64 message
  • message is the data you are hashing.

blake2bWithKey Source #

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
  • key is the BLAKE2b key.
  • message is 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.

sha256 #

Arguments

:: (ByteArrayAccess pt, ByteArray hashBytes) 
=> pt

Message to hash

-> HashSha256 hashBytes 

Hash a message using SHA-256.

hash = Hash.sha256 message
  • message is the data you are hashing.

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.

sha512 #

Arguments

:: (ByteArrayAccess pt, ByteArray hashBytes) 
=> pt

Message to hash

-> HashSha512 hashBytes 

Hash a message using SHA-512.

hash = Hash.sha512 message
  • message is the data you are hashing.