{-# LANGUAGE BangPatterns #-}
module Data.ByteArray.Hash
(
SipKey(..)
, SipHash(..)
, sipHash
, sipHashWith
, FnvHash32(..)
, FnvHash64(..)
, fnv1Hash
, fnv1aHash
, fnv1_64Hash
, fnv1a_64Hash
) where
import Data.Memory.Internal.Compat
import Data.Memory.Hash.SipHash
import Data.Memory.Hash.FNV
import qualified Data.ByteArray.Types as B
sipHash :: B.ByteArrayAccess ba
=> SipKey
-> ba
-> SipHash
sipHash key ba = unsafeDoIO $ B.withByteArray ba $ \p -> hash key p (B.length ba)
sipHashWith :: B.ByteArrayAccess ba
=> Int
-> Int
-> SipKey
-> ba
-> SipHash
sipHashWith c d key ba = unsafeDoIO $ B.withByteArray ba $ \p -> hashWith c d key p (B.length ba)
fnv1Hash :: B.ByteArrayAccess ba
=> ba
-> FnvHash32
fnv1Hash ba = unsafeDoIO $ B.withByteArray ba $ \p -> fnv1 p (B.length ba)
fnv1aHash :: B.ByteArrayAccess ba
=> ba
-> FnvHash32
fnv1aHash ba = unsafeDoIO $ B.withByteArray ba $ \p -> fnv1a p (B.length ba)
fnv1_64Hash :: B.ByteArrayAccess ba
=> ba
-> FnvHash64
fnv1_64Hash ba = unsafeDoIO $ B.withByteArray ba $ \p -> fnv1_64 p (B.length ba)
fnv1a_64Hash :: B.ByteArrayAccess ba
=> ba
-> FnvHash64
fnv1a_64Hash ba = unsafeDoIO $ B.withByteArray ba $ \p -> fnv1a_64 p (B.length ba)