Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (15 sloc) 516 Bytes
import Crypto.Hash
import Data.ByteString (ByteString)
import qualified Data.ByteString.UTF8 as UTF8
import Data.ByteArray.Encoding
sha256 :: String -> String
sha256 input = result
where
bytes = UTF8.fromString input :: ByteString
digest = hashWith SHA256 bytes :: Digest SHA256
hex = convertToBase Base16 digest :: ByteString
result = UTF8.toString hex :: String
main =
do
putStrLn ("sha256(abc) = " ++ sha256 "abc")
putStrLn ("sha256(hello) = " ++ sha256 "hello")
You can’t perform that action at this time.