add argon2
This commit is contained in:
parent
f829d14384
commit
c99bca0511
3 changed files with 15 additions and 9 deletions
|
@ -36,7 +36,7 @@ library
|
||||||
API
|
API
|
||||||
Classes
|
Classes
|
||||||
Util
|
Util
|
||||||
Util.Random
|
Util.Crypto
|
||||||
Model.Product
|
Model.Product
|
||||||
Model.Auth
|
Model.Auth
|
||||||
Model.User
|
Model.User
|
||||||
|
|
14
src/Util/Crypto.hs
Normal file
14
src/Util/Crypto.hs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
module Util.Crypto where
|
||||||
|
|
||||||
|
import Crypto.KDF.Argon2
|
||||||
|
import Crypto.Error (CryptoFailable)
|
||||||
|
|
||||||
|
import qualified Data.ByteString as BS
|
||||||
|
|
||||||
|
import System.Random.Stateful (uniformByteStringM, newIOGenM, mkStdGen)
|
||||||
|
|
||||||
|
randomString :: IO BS.ByteString
|
||||||
|
randomString = uniformByteStringM 32 =<< newIOGenM (mkStdGen 23)
|
||||||
|
|
||||||
|
argon2 :: BS.ByteString -> BS.ByteString -> CryptoFailable BS.ByteString
|
||||||
|
argon2 salt payload = hash defaultOptions payload salt 64
|
|
@ -1,8 +0,0 @@
|
||||||
module Util.Random where
|
|
||||||
|
|
||||||
import qualified Data.ByteString as BS
|
|
||||||
|
|
||||||
import System.Random.Stateful (uniformByteStringM, newIOGenM, mkStdGen)
|
|
||||||
|
|
||||||
randomString :: IO BS.ByteString
|
|
||||||
randomString = uniformByteStringM 32 =<< newIOGenM (mkStdGen 23)
|
|
Loading…
Reference in a new issue