diff --git a/Crypto/Tutorial.hs b/Crypto/Tutorial.hs new file mode 100644 index 0000000..83487c7 --- /dev/null +++ b/Crypto/Tutorial.hs @@ -0,0 +1,34 @@ +{-# OPTIONS_GHC -fno-warn-unused-imports #-} +{-# LANGUAGE OverloadedStrings #-} + +{-| How to use @cryptonite@ + +> -- | Beware MUST BE 256bits as we use AES256 +> import Data.ByteString (ByteString) +> import Crypto.Cipher.AES (AES256) +> import Crypto.Cipher.Types (BlockCipher(..), Cipher(..),nullIV) +> import Crypto.Error (CryptoFailable(..)) +> +> secretKey :: ByteString +> secretKey = "012-456-89A-CDE-012-456-89A-CDE-" +> +> encrypt :: ByteString -> ByteString -> ByteString +> encrypt secret = ctrCombine ctx nullIV +> where +> ctx = cipherInitNoErr (cipherMakeKey (undefined :: AES256) secret) +> cipherInitNoErr :: BlockCipher c => Key c -> c +> cipherInitNoErr (Key k) = case cipherInit k of +> CryptoPassed a -> a +> CryptoFailed e -> error (show e) +> cipherMakeKey :: Cipher cipher => cipher -> ByteString -> Key cipher +> cipherMakeKey _ = Key -- Yeah Lazyness!!!!!! +> +> +> decrypt :: ByteString -> ByteString -> ByteString +> decrypt = encrypt + +|-} + +module Crypto.Tutorial () where + +import Crypto.Cipher.Types diff --git a/cryptonite.cabal b/cryptonite.cabal index c2dc811..25e0ccd 100644 --- a/cryptonite.cabal +++ b/cryptonite.cabal @@ -23,6 +23,8 @@ Description: cryptographic kitchen sink that provides cryptography for everyone. . Evaluate the security related to your requirements before using. + . + Read "Crypto.Tutorial" for a quick start guide. License: BSD3 License-file: LICENSE Copyright: Vincent Hanquez @@ -139,6 +141,7 @@ Library Crypto.Random.Entropy Crypto.Random.EntropyPool Crypto.Random.Entropy.Unsafe + Crypto.Tutorial Other-modules: Crypto.Cipher.AES.Primitive Crypto.Cipher.Blowfish.Box Crypto.Cipher.Blowfish.Primitive