Safe Haskell | Trustworthy |
---|---|

Language | Haskell2010 |

The Fowler–Noll–Vo or FNV hash function, a simple and fast hash function suitable for use in a bloom filter.

See http://www.isthe.com/chongo/tech/comp/fnv for further information.

## Synopsis

- fnv1 :: (Binary a, FiniteBits b, Num b) => a -> b
- fnv1a :: (Binary a, FiniteBits b, Num b) => a -> b
- fnv0 :: (Binary a, Num b, FiniteBits b) => a -> b
- fnvPrime :: forall a. (Num a, FiniteBits a) => a
- fnvOffsetBasis :: (FiniteBits a, Num a) => a

# Hash functions

fnv1 :: (Binary a, FiniteBits b, Num b) => a -> b Source #

Variant 1 of the FNV hash function.
The hash is first multiplied with the `fnvPrime`

and then `xor`

ed with the octet.

fnv1a :: (Binary a, FiniteBits b, Num b) => a -> b Source #

Variant 1a of the FNV hash function.
The hash is first `xor`

ed with the octet and then multiplied with the `fnvPrime`

.

## Historical

fnv0 :: (Binary a, Num b, FiniteBits b) => a -> b Source #

Variant 0 is historical and should not be used directly.
Rather, it is used to calculate the offset basis (`fnvOffsetBasis`

)
of the algorithm (`fnv1`

and `fnv1a`

).

# Auxiliary constants

fnvPrime :: forall a. (Num a, FiniteBits a) => a Source #

The FNV prime. The prime is calculated
automatically based on the number of bits
in the resulting type.
However, primes for `2^n`

where `n`

is not
in the range `5..9`

are not (officialy)
supported.

fnvOffsetBasis :: (FiniteBits a, Num a) => a Source #