Created
October 7, 2016 18:47
-
-
Save tippenein/582afd7e6bcee54e98b384d976af94e3 to your computer and use it in GitHub Desktop.
sha256 hash file(s) from command line
This file contains hidden or 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
#!/usr/bin/env runhaskell | |
import Crypto.Hash | |
import Data.ByteString | |
import Prelude hiding (readFile) | |
import System.Environment (getArgs) | |
keyFor :: FilePath -> IO () | |
keyFor filepath = do | |
bytes <- readFile filepath | |
print $ hexSha3_256 bytes | |
sha1 :: ByteString -> Digest SHA1 | |
sha1 = hash | |
hexSha3_256 :: ByteString -> String | |
hexSha3_256 bs = show (hash bs :: Digest SHA3_256) | |
main :: IO () | |
main = do | |
args <- getArgs | |
case args of | |
[] -> print "gimme filepath(s)" | |
[filepath] -> keyFor filepath | |
filepaths -> mapM_ keyFor filepaths |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment