Data.ByteArray.Hash

memory-0.11: memory and related abstraction stuff

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

Data.ByteArray.Hash

Contents

- SipHash
- FNV1 and FNV1a (32 and 64 bits)

Description

provide the SipHash algorithm. reference: http://131002.net/siphash/siphash.pdf

Synopsis

- data SipKey = SipKey !Word64 !Word64
- newtype SipHash = SipHash Word64
- sipHash :: ByteArrayAccess ba => SipKey -> ba -> SipHash
- sipHashWith :: ByteArrayAccess ba => Int -> Int -> SipKey -> ba -> SipHash
- newtype FnvHash32 = FnvHash32 Word32
- newtype FnvHash64 = FnvHash64 Word64
- fnv1Hash :: ByteArrayAccess ba => ba -> FnvHash32
- fnv1aHash :: ByteArrayAccess ba => ba -> FnvHash32
- fnv1_64Hash :: ByteArrayAccess ba => ba -> FnvHash64
- fnv1a_64Hash :: ByteArrayAccess ba => ba -> FnvHash64

# SipHash

data SipKey

SigHash Key

Constructors

SipKey !Word64 !Word64 |

newtype SipHash

Siphash tag value

Constructors

SipHash Word64 |

Instances

Eq SipHash |
Ord SipHash |
Show SipHash |

sipHash :: ByteArrayAccess ba => SipKey -> ba -> SipHash

Compute the SipHash tag of a byte array for a given key.

`sipHash` is equivalent to 'sipHashWith 2 4'

sipHashWith

Arguments

:: ByteArrayAccess ba |
=> Int | c rounds
-> Int | d rounds
-> SipKey | key
-> ba | data to hash
-> SipHash |

Compute the SipHash tag of a byte array for a given key.

The user can choose the C and D numbers of rounds.

calling `sipHash` is equivalent to 'sipHashWith 2 4'

# FNV1 and FNV1a (32 and 64 bits)

newtype FnvHash32

FNV1(a) hash (32 bit variants)

Constructors

FnvHash32 Word32 |

Instances

Eq FnvHash32 |
Ord FnvHash32 |
Show FnvHash32 |
NFData FnvHash32 |

newtype FnvHash64

FNV1(a) hash (64 bit variants)

Constructors

FnvHash64 Word64 |

Instances

Eq FnvHash64 |
Ord FnvHash64 |
Show FnvHash64 |
NFData FnvHash64 |

fnv1Hash :: ByteArrayAccess ba => ba -> FnvHash32

Compute the FNV1 32 bit hash value of a byte array

fnv1aHash :: ByteArrayAccess ba => ba -> FnvHash32

Compute the FNV1a 32 bit hash value of a byte array

fnv1_64Hash :: ByteArrayAccess ba => ba -> FnvHash64

Compute the FNV1 64 bit hash value of a byte array

fnv1a_64Hash :: ByteArrayAccess ba => ba -> FnvHash64

Compute the FNV1a 64 bit hash value of a byte array