uuid 1.2.4 → 1.2.5
raw patch · 7 files changed
+33/−41 lines, 7 filesdep +cryptohashdep −Crypto
Dependencies added: cryptohash
Dependencies removed: Crypto
Files
- CHANGES +8/−0
- CONTRIBUTORS +2/−0
- Data/UUID/Internal.hs +2/−1
- Data/UUID/Named.hs +12/−7
- Data/UUID/V3.hs +2/−24
- Data/UUID/V5.hs +3/−5
- uuid.cabal +4/−4
CHANGES view
@@ -1,6 +1,14 @@+1.2.5++- Use 'cryptohash' package for MD5 and SHA1 instead of 'Crypto'+ 1.2.4 - Unpack Word32 values into UUID constructor.++- Update test suite to QuickCheck 2++- Bump other dependencies in tests/benchmarks 1.2.3
CONTRIBUTORS view
@@ -4,3 +4,5 @@ Jason Dusek Tim Newsham Mark Lentczner+Neil Mitchell+Bas van Dijk
Data/UUID/Internal.hs view
@@ -21,6 +21,7 @@ ,toString ,fromWords ,toWords+ ,toList ,buildFromBytes ,buildFromWords ) where@@ -55,7 +56,7 @@ -- version 4 UUIDs as specified in RFC 4122. The 'Storable' and -- 'Binary' instances are compatible with RFC 4122, storing the fields -- in network order as 16 bytes.-data UUID +data UUID = UUID {-# UNPACK #-} !Word32 {-# UNPACK #-} !Word32
Data/UUID/Named.hs view
@@ -28,23 +28,28 @@ import Data.UUID.Internal -import Data.Binary+import Control.Applicative ((<*>),(<$>))+import Data.Binary.Get (runGet, getWord32be) import Data.Maybe+import Data.Word (Word8) -import qualified Data.ByteString.Lazy as BS+import qualified Data.ByteString as B+import qualified Data.ByteString.Lazy as BL -- |Generate a 'UUID' within the specified namespace out of the given -- object.-generateNamed :: ([Word8] -> (Word32, Word32, Word32, Word32)) -- ^Hash+generateNamed :: (B.ByteString -> B.ByteString) -- ^Hash -> Word8 -- ^Version -> UUID -- ^Namespace -> [Word8] -- ^Object -> UUID generateNamed hash version namespace object =- let chunk = BS.unpack (toByteString namespace) ++ object- (w1, w2, w3, w4) = hash chunk- in buildFromWords version w1 w2 w3 w4-+ let chunk = B.pack $ toList namespace ++ object+ bytes = BL.fromChunks . (:[]) $ hash chunk+ w = getWord32be+ unpackBytes = runGet $+ buildFromWords version <$> w <*> w <*> w <*> w+ in unpackBytes bytes unsafeFromString :: String -> UUID
Data/UUID/V3.hs view
@@ -27,11 +27,10 @@ ) where import Data.Word-import Data.Bits import Data.UUID.Internal import qualified Data.UUID.Named as Shared-import qualified Data.Digest.MD5 as MD5+import qualified Crypto.Hash.MD5 as MD5 -- |Generate a 'UUID' within the specified namespace out of the given@@ -42,26 +41,5 @@ generateNamed :: UUID -- ^Namespace -> [Word8] -- ^Object -> UUID-generateNamed = Shared.generateNamed hash 3--hash :: [Word8] -> (Word32, Word32, Word32, Word32)-hash bytes- = case map f $ chunk 4 $ MD5.hash bytes of- w1:w2:w3:w4:_ -> (w1, w2, w3, w4)- _ -> error "Data.UUID.V3.hash: fatal error"-- where f [b1, b2, b3, b4]- = sum- [ fromIntegral b4- , fromIntegral b3 `shiftL` 8- , fromIntegral b2 `shiftL` 16- , fromIntegral b1 `shiftL` 24- ]- f _ = error "Data.UUID.V3.hash: fatal error"+generateNamed = Shared.generateNamed MD5.hash 3 -chunk :: Int -> [a] -> [[a]]-chunk n = go n []- where go _ [] [] = []- go _ ys [] = reverse ys:[]- go 0 ys xs = reverse ys:go n [] xs- go m ys (x:xs) = go (m-1) (x:ys) xs
Data/UUID/V5.hs view
@@ -30,7 +30,7 @@ import Data.UUID.Internal import qualified Data.UUID.Named as Shared-import qualified Data.Digest.SHA1 as SHA1+import qualified Crypto.Hash.SHA1 as SHA1 -- |Generate a 'UUID' within the specified namespace out of the given@@ -41,7 +41,5 @@ generateNamed :: UUID -- ^Namespace -> [Word8] -- ^Object -> UUID-generateNamed = Shared.generateNamed hash 5- where hash bytes- = case SHA1.hash bytes of- SHA1.Word160 w1 w2 w3 w4 _w5 -> (w1, w2, w3, w4)+generateNamed = Shared.generateNamed SHA1.hash 5+
uuid.cabal view
@@ -1,5 +1,5 @@ Name: uuid-Version: 1.2.4+Version: 1.2.5 Copyright: (c) 2008-2012 Antoine Latter Author: Antoine Latter Maintainer: aslatter@gmail.com@@ -13,7 +13,7 @@ Description: This library is useful for creating, comparing, parsing and printing Universally Unique Identifiers.- See <http://en.wikipedia.org/wiki/UUID> for the general idea. + See <http://en.wikipedia.org/wiki/UUID> for the general idea. Synopsis: For creating, comparing, parsing and printing Universally Unique Identifiers @@ -26,8 +26,8 @@ Library- Build-Depends: random, binary, bytestring, Crypto, maccatcher,- time, base >=3, base < 5+ Build-Depends: random, binary, bytestring, cryptohash >= 0.7 && < 0.8, maccatcher,+ time, base >=3 && < 5 Exposed-Modules: Data.UUID