Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make hash appears before hashWith

  • Loading branch information...
commit c8005474dffe94e83d00587d8d79bd67109dd17a 1 parent f64d2da
@vincenthz authored
Showing with 5 additions and 5 deletions.
  1. +5 −5 Crypto/MAC/SipHash.hs
View
10 Crypto/MAC/SipHash.hs
@@ -11,8 +11,8 @@
module Crypto.MAC.SipHash
( SipKey(..)
, SipHash(..)
- , hashWith
, hash
+ , hashWith
) where
import Data.Word
@@ -32,6 +32,10 @@ newtype SipHash = SipHash Word64
data InternalState = InternalState {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64 {-# UNPACK #-} !Word64
+-- | 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
@@ -48,10 +52,6 @@ hashWith c d key b = either error (finish d) $ runGet runHash b
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)
(k0 `xor` 0x6c7967656e657261)

0 comments on commit c800547

Please sign in to comment.
Something went wrong with that request. Please try again.