on master help sign in
Use cryptohash instead of Crypto

Crypto doesn't build on GHC-7.4 anymore. I mailed the maintainer a patch but I was told it was deprecated. So I switched uuid over to cryptohash.

commite24d8b27a2572901c01e03f90209c6a73c55cced authorBas van Dijk <v.dijk.bas@gmail.com> dateTue 27 Mar 2012, 08:51 (15 years ago) parent4b19c2c
3 files changed+22−7
Data/UUID/V3.hs+3−2 Data/UUID/V5.hs+17−3 uuid.cabal+2−2
Data/UUID/V3.hs+3−2
@@ -28,10 +28,11 @@ module Data.UUID.V3
2828
2929import Data.Word
3030import Data.Bits
31+import qualified Data.ByteString as B
3132
3233import Data.UUID.Internal
3334import qualified Data.UUID.Named as Shared
34−import qualified Data.Digest.MD5 as MD5
35+import qualified Crypto.Hash.MD5 as MD5
3536
3637
3738-- |Generate a 'UUID' within the specified namespace out of the given
@@ -46,7 +47,7 @@ generateNamed = Shared.generateNamed hash 3
4647
4748hash :: [Word8] -> (Word32, Word32, Word32, Word32)
4849hash bytes
49− = case map f $ chunk 4 $ MD5.hash bytes of
50+ = case map f $ chunk 4 $ B.unpack $ MD5.hash $ B.pack bytes of
5051 w1:w2:w3:w4:_ -> (w1, w2, w3, w4)
5152 _ -> error "Data.UUID.V3.hash: fatal error"
5253
Data/UUID/V5.hs+17−3
@@ -27,10 +27,12 @@ module Data.UUID.V5
2727 ) where
2828
2929import Data.Word
30+import Data.Bits
31+import qualified Data.ByteString as B
3032
3133import Data.UUID.Internal
3234import qualified Data.UUID.Named as Shared
33−import qualified Data.Digest.SHA1 as SHA1
35+import qualified Crypto.Hash.SHA1 as SHA1
3436
3537
3638-- |Generate a 'UUID' within the specified namespace out of the given
@@ -43,5 +45,17 @@ generateNamed :: UUID -- ^Namespace
4345 -> UUID
4446generateNamed = Shared.generateNamed hash 5
4547 where hash bytes
46− = case SHA1.hash bytes of
47− SHA1.Word160 w1 w2 w3 w4 _w5 -> (w1, w2, w3, w4)
48+ = case B.unpack $ SHA1.hash $ B.pack bytes of
49+ a1:b1:c1:d1: a2:b2:c2:d2: a3:b3:c3:d3: a4:b4:c4:d4:_ ->
50+ ( toWord a1 b1 c1 d1
51+ , toWord a2 b2 c2 d2
52+ , toWord a3 b3 c3 d3
53+ , toWord a4 b4 c4 d4
54+ )
55+ _ -> error "Data.UUID.V5.hash: fatal error"
56+
57+toWord :: Word8 -> Word8 -> Word8 -> Word8 -> Word32
58+toWord a b c d = fromIntegral a `shiftL` 24
59+ .|. fromIntegral b `shiftL` 16
60+ .|. fromIntegral c `shiftL` 8
61+ .|. fromIntegral d
uuid.cabal+2−2
@@ -13,7 +13,7 @@ Cabal-Version: >= 1.8
1313Description:
1414 This library is useful for creating, comparing, parsing and
1515 printing Universally Unique Identifiers.
16− See <http://en.wikipedia.org/wiki/UUID> for the general idea.
16+ See <http://en.wikipedia.org/wiki/UUID> for the general idea.
1717
1818Synopsis: For creating, comparing, parsing and printing Universally Unique Identifiers
1919
@@ -26,7 +26,7 @@ Extra-Source-Files:
2626
2727
2828Library
29− Build-Depends: random, binary, bytestring, Crypto, maccatcher,
29+ Build-Depends: random, binary, bytestring, cryptohash, maccatcher,
3030 time, base >=3, base < 5
3131
3232 Exposed-Modules: