summaryrefslogtreecommitdiff
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
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."
-rw-r--r--hakyll.cabal3
-rw-r--r--lib/Hakyll/Core/Store.hs18
2 files changed, 18 insertions, 3 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 90ba220..288a616 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -170,13 +170,14 @@ Library
blaze-markup >= 0.5.1 && < 0.9,
bytestring >= 0.9 && < 0.11,
containers >= 0.3 && < 0.7,
- cryptohash >= 0.7 && < 0.12,
+ cryptonite >= 0.25 && < 0.26,
data-default >= 0.4 && < 0.8,
deepseq >= 1.3 && < 1.5,
directory >= 1.0 && < 1.4,
file-embed >= 0.0.10.1 && < 0.0.12,
filepath >= 1.0 && < 1.5,
lrucache >= 1.1.1 && < 1.3,
+ memory >= 0.14.18 && < 0.15,
mtl >= 1 && < 2.3,
network-uri >= 2.6 && < 2.7,
optparse-applicative >= 0.12 && < 0.16,
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