BCrypt hash a String in Haskell
Just wanted to see if I could make this in haskell.
import Crypto.KDF.BCrypt (hashPassword)
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Base64 (encode,decode)
import System.Environment
runArgs :: [String] -> IO B.ByteString
runArgs [a] = do
hash a
hash :: String -> IO B.ByteString
hash a = hashPassword 6 (B.pack a) :: IO B.ByteString
main :: IO ()
main = do
args <- getArgs
b <- runArgs args
putStrLn (show b)
I think this works.... The output validates with the python code below so...
#!/usr/bin/env python3
import bcrypt
import sys
passwd = sys.argv[1].encode("utf-8")
hashed = sys.argv[2].encode("utf-8")
if bcrypt.checkpw(passwd, hashed):
print("match")
else:
print("does not match")