|
|
|
|
|
by mrkgnao
3219 days ago
|
|
The extensive README is also a pretty good intro to how one can do crypto (as in cryptography: get off my lawn!) in Haskell using the excellent cryptonite library. For those who won't click through to TFR: > import Crypto.Number.Hash (SHA3_256)
> import Crypto.PubKey.ECC.ECDSA (sign, verify)
> import Crypto.PubKey.ECC.Generate (generate)
> import Crypto.PubKey.ECC.Types (getCurveByName, SEC_p256k1)
> let msg = "hello world" :: ByteString
> let secp256k1 = getCurveByName SEC_p256k1
> (pubKey, privKey) <- generate secp256k1
> sig <- sign privKey SHA3_256 msg
> verify SHA3_256 pubKey sig msg
True
|
|
Something I didn't like about it is that it exposes crypto primitives, including stuff like TripleDES, with no warning[0]. The tutorial also has you handle IVs directly.[1]
[0] https://hackage.haskell.org/package/cryptonite-0.24/docs/Cry...
[1] https://hackage.haskell.org/package/cryptonite-0.24/docs/Cry...