summaryrefslogtreecommitdiff
path: root/lib/Hakyll/Core/Store.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Hakyll/Core/Store.hs')
-rw-r--r--lib/Hakyll/Core/Store.hs18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Hakyll/Core/Store.hs b/lib/Hakyll/Core/Store.hs
index f65a00b..bfcd191 100644
--- a/lib/Hakyll/Core/Store.hs
+++ b/lib/Hakyll/Core/Store.hs
@@ -16,7 +16,8 @@ module Hakyll.Core.Store
--------------------------------------------------------------------------------
-import qualified Crypto.Hash.MD5 as MD5
+import qualified Data.ByteArray as BA
+import qualified Crypto.Hash as CH
import Data.Binary (Binary, decode, encodeFile)
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as BL
@@ -193,8 +194,21 @@ deleteFile = (`catchIOError` \_ -> return ()) . removeFile
--------------------------------------------------------------------------------
-- | Mostly meant for internal usage
hash :: [String] -> String
-hash = toHex . B.unpack . MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"
+hash = toHex . B.unpack . hashMD5 . T.encodeUtf8 . T.pack . intercalate "/"
where
toHex [] = ""
toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs)
| otherwise = showHex x (toHex xs)
+
+
+--------------------------------------------------------------------------------
+-- | Hash by MD5
+hashMD5 :: B.ByteString -> B.ByteString
+hashMD5 x =
+ let
+ digest :: CH.Digest CH.MD5
+ digest = CH.hash x
+ bytes :: B.ByteString
+ bytes = BA.convert digest
+ in
+ bytes