pureMD5 1.0.0.3 → 1.1.0.0
raw patch · 2 files changed
+43/−21 lines, 2 filesdep +cerealdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: cereal
Dependency ranges changed: base
API changes (from Hackage documentation)
+ Data.Digest.Pure.MD5: instance Serialize MD5Context
+ Data.Digest.Pure.MD5: instance Serialize MD5Digest
+ Data.Digest.Pure.MD5: instance Serialize MD5Partial
Files
- Data/Digest/Pure/MD5.hs +39/−14
- pureMD5.cabal +4/−7
Data/Digest/Pure/MD5.hs view
@@ -46,6 +46,9 @@ import Data.Binary import Data.Binary.Get import Data.Binary.Put+import qualified Data.Serialize.Get as G+import qualified Data.Serialize.Put as P+import qualified Data.Serialize as S import Numeric -- | Block size in bits@@ -119,10 +122,7 @@ -- context across calls to applyMD5Rounds. performMD5Update :: MD5Context -> ByteString -> MD5Context performMD5Update !ctx@(MD5Ctx !par@(MD5Par !a !b !c !d) _ !len) !bs = {-# SCC "performMD5Update" #-}- let MD5Par a' b' c' d' = {- if isAligned bs- then applyMD5Rounds par bs getAlignedNthWord- else applyMD5Rounds par bs getUnalignedNthWord -}- applyMD5Rounds par bs+ let MD5Par a' b' c' d' = applyMD5Rounds par bs in MD5Ctx { mdPartial = MD5Par (a' + a) (b' + b) (c' + c) (d' + d), mdLeftOver = B.empty,@@ -236,10 +236,12 @@ {-# INLINE (!!) #-} {-# INLINE applyMD5Rounds #-} -getNthWord n bs@(PS ptr off len) =- inlinePerformIO $ withForeignPtr ptr $ \ptr' -> do- let p = castPtr $ plusPtr ptr' off- peekElemOff p n+getNthWord :: Int -> B.ByteString -> Word32+getNthWord n = right . G.runGet (do+ G.uncheckedSkip (n * sizeOf (undefined :: Word32))+ G.getWord32le)+ where+ right x = case x of Right y -> y {-# INLINE getNthWord #-} infix 9 .<.@@ -251,12 +253,6 @@ instance Show MD5Digest where show (MD5Digest h) = show h -instance Binary MD5Digest where- put (MD5Digest p) = put p- get = do- p <- get- return $ MD5Digest p- instance Show MD5Partial where show (MD5Par a b c d) = let bs = runPut $ putWord32be d >> putWord32be c >> putWord32be b >> putWord32be a@@ -265,6 +261,12 @@ then '0':c else c) "" (L.unpack bs) +instance Binary MD5Digest where+ put (MD5Digest p) = put p+ get = do+ p <- get+ return $ MD5Digest p+ instance Binary MD5Context where put (MD5Ctx p r l) = put p >> putWord8 (fromIntegral (B.length r)) >> putByteString r >> putWord64be l@@ -281,3 +283,26 @@ c <- getWord32le d <- getWord32le return $ MD5Par a b c d++instance S.Serialize MD5Digest where+ put (MD5Digest p) = S.put p+ get = do+ p <- S.get+ return $ MD5Digest p++instance S.Serialize MD5Context where+ put (MD5Ctx p r l) = S.put p >> P.putWord8 (fromIntegral (B.length r)) >>+ P.putByteString r >> P.putWord64be l+ get = do p <- S.get+ s <- G.getWord8+ r <- G.getByteString (fromIntegral s)+ l <- G.getWord64be+ return $ MD5Ctx p r l++instance S.Serialize MD5Partial where+ put (MD5Par a b c d) = P.putWord32le a >> P.putWord32le b >> P.putWord32le c >> P.putWord32le d+ get = do a <- G.getWord32le+ b <- G.getWord32le+ c <- G.getWord32le+ d <- G.getWord32le+ return $ MD5Par a b c d
pureMD5.cabal view
@@ -1,5 +1,5 @@ name: pureMD5-version: 1.0.0.3+version: 1.1.0.0 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>@@ -9,15 +9,12 @@ category: Data, Cryptography stability: stable build-type: Simple-cabal-version: >= 1.2+cabal-version: >= 1.6 tested-with: GHC == 6.10.1 extra-source-files: Test/MD5.hs Test/md5test.hs -Flag small_base- Description: Choose the split-up base package.- Library- Build-Depends: base >= 3 && < 5, bytestring >= 0.9 && < 0.10, binary >= 0.4.0 && < 0.6.0+ Build-Depends: base == 4.*, bytestring >= 0.9 && < 0.10, binary >= 0.4.0 && < 0.6.0, cereal >= 0.2+ ghc-options: -O2 -funfolding-use-threshold66 -funfolding-creation-threshold66 -fexcess-precision -funbox-strict-fields hs-source-dirs: exposed-modules: Data.Digest.Pure.MD5- ghc-options: -O2 -funfolding-use-threshold66 -funfolding-creation-threshold66 -fexcess-precision -funbox-strict-fields