summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHexirp <Hexirp@users.noreply.github.com>2020-02-26 20:19:39 +0900
committerGitHub <noreply@github.com>2020-02-26 12:19:39 +0100
commitd291036c93d0258dcd8a2172004c9b8449a8a824 (patch)
tree74a62df6ec4def5d7c50a4164033d5ff48b3367e /lib
parent7bb38b456ade0b6869b97776fdc0a0111697e401 (diff)
downloadhakyll-d291036c93d0258dcd8a2172004c9b8449a8a824.tar.gz
Use 'cryptonite' instead of 'cryptohash'
'cryptohash' is deprecated. The package description says, "please use cryptonite for new projects and convert old one to use cryptonite."
Diffstat (limited to 'lib')
-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