Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {-# LANGUAGE KindSignatures #-}
- {-# LANGUAGE DataKinds #-}
- {-# LANGUAGE ScopedTypeVariables #-}
- module Key (Key, makeKey) where
- import Data.ByteString (ByteString)
- import qualified Data.ByteString as B
- import Data.Proxy
- import GHC.TypeLits
- newtype Key (size :: Nat) = Key ByteString
- deriving (Show)
- makeKey :: forall size. KnownNat size => ByteString -> Maybe (Key size)
- makeKey s | B.length s == (keyLength `div` 8) = Just (Key s)
- | otherwise = Nothing
- where
- keyLength = fromInteger $ natVal (Proxy :: Proxy size)
- --encrypt :: Key 96 -> Key 256 -> String -> String
- --encrypt (Key nonce) (Key cipherKey) plaintext = undefined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement