-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
561f36e
commit 26b9cea
Showing
4 changed files
with
23 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sha256(abc) = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad | ||
sha256(hello) = 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters