siphash 1.0.0 → 1.0.1
raw patch · 2 files changed
+8/−8 lines, 2 files
Files
- Crypto/MAC/SipHash.hs +7/−7
- siphash.cabal +1/−1
Crypto/MAC/SipHash.hs view
@@ -6,13 +6,13 @@ -- Portability : good -- -- provide the SipHash algorithm.--- reference: http://131002.net/siphash/siphash.pdf+-- reference: <http://131002.net/siphash/siphash.pdf> -- module Crypto.MAC.SipHash ( SipKey(..) , SipHash(..)- , hashWith , hash+ , hashWith ) where import Data.Word@@ -32,7 +32,11 @@ data InternalState = InternalState {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 --- | same as @hash, except also specifies the number of sipround iterations for compression and digest.+-- | produce a siphash with a key and a bytestring.+hash :: SipKey -> ByteString -> SipHash+hash = hashWith 2 4++-- | same as 'hash', except also specifies the number of sipround iterations for compression and digest. hashWith :: Int -> Int -> SipKey -> ByteString -> SipHash hashWith c d key b = either error (finish d) $ runGet runHash b where len = B.length b@@ -47,10 +51,6 @@ shiftAndAdd :: (Word64,Int) -> Word8 -> (Word64,Int) shiftAndAdd (acc,pos) v = (acc .|. ((fromIntegral v) `shiftL` pos), pos+8)---- | produce a siphash with a key and a bytestring.-hash :: SipKey -> ByteString -> SipHash-hash = hashWith 2 4 initSip (SipKey k0 k1) = InternalState (k0 `xor` 0x736f6d6570736575) (k1 `xor` 0x646f72616e646f6d)
siphash.cabal view
@@ -1,5 +1,5 @@ Name: siphash-Version: 1.0.0+Version: 1.0.1 Description: Haskell implementation of siphash. [http://131002.net/siphash/siphash.pdf] License: BSD3