pureMD5 0.2.2 → 0.2.3
raw patch · 2 files changed
+15/−16 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Data/Digest/Pure/MD5.hs +14/−15
- pureMD5.cabal +1/−1
Data/Digest/Pure/MD5.hs view
@@ -99,32 +99,31 @@ -- | Alters the MD5Context with a partial digest of the data. md5Update :: MD5Context -> L.ByteString -> MD5Context md5Update !ctx@(MD5Ctx _ !leftover _) bsLazy =- let bs = L.fromChunks (leftover:L.toChunks bsLazy)- blks = block bs- in foldl' performMD5Update ctx blks+ let bs = L.fromChunks (leftover:L.toChunks bsLazy)+ in blockAndDo ctx bs --foldl' performMD5Update ctx blks -block :: L.ByteString -> [ByteString]-block bs =- if rest /= L.empty- then (conv top) : (block rest)- else [conv top]- where- conv = B.concat . L.toChunks- (top,rest) = L.splitAt blockSizeBytesI64 bs-{-# INLINE block #-}+blockAndDo :: MD5Context -> L.ByteString -> MD5Context+blockAndDo !ctx bs =+ if B.length blk == blockSizeBytes+ then let !newCtx = performMD5Update ctx blk+ in blockAndDo newCtx rest+ else ctx { mdLeftOver = blk }+ where+ blk = B.concat $ L.toChunks top+ (top,rest) = L.splitAt blockSizeBytesI64 bs+{-# INLINE blockAndDo #-} -- Assumes ByteString length == blockSizeBytes, will fold the -- context across calls to applyMD5Rounds. performMD5Update :: MD5Context -> ByteString -> MD5Context performMD5Update !ctx@(MD5Ctx !par@(MD5Par !a !b !c !d) _ !len) !bs = let MD5Par a' b' c' d' = applyMD5Rounds par bs- in if B.length bs == blockSizeBytes- then MD5Ctx {+ in MD5Ctx { mdPartial = MD5Par (a' + a) (b' + b) (c' + c) (d' + d), mdLeftOver = B.empty, mdTotalLen = len + blockSizeBits }- else ctx { mdLeftOver = bs } +{-# INLINE performMD5Update #-} applyMD5Rounds :: MD5Partial -> ByteString -> MD5Partial applyMD5Rounds par@(MD5Par a b c d) w =
pureMD5.cabal view
@@ -1,5 +1,5 @@ name: pureMD5-version: 0.2.2+version: 0.2.3 license: BSD3 license-file: LICENSE author: Thomas DuBuisson <thomas.dubuisson@gmail.com>