Web.ClientSession
- getKey :: FilePath -> IO Key
- defaultKeyFile :: String
- getDefaultKey :: IO Key
- encrypt :: Key -> ByteString -> IO String
- decrypt :: (Monad m, Failure ClientSessionException m) => Key -> String -> m ByteString
- data ClientSessionException
Automatic key generation
Get a key from the given text file.
If the file does not exist a random key will be generated and stored in that file.
defaultKeyFile :: StringSource
The default key file.
Simply calls getKey "client_session_key.aes"
Actual encryption/decryption
Arguments
| :: Key | The key used for encryption. |
| -> ByteString | The data to encrypt. |
| -> IO String | Encrypted and encoded data. |
Encrypt with the given key and base-64 encode. A hash is stored inside the encrypted key so that, upon decryption, integrity can be guaranteed.
Arguments
| :: (Monad m, Failure ClientSessionException m) | |
| => Key | The key used for encryption. |
| -> String | Data to decrypt. |
| -> m ByteString | The decrypted data, if possible. |
Base-64 decode and decrypt with the given key, if possible. Calls
failure if either the original string is not a valid base-64 encoded
string, or the hash at the beginning of the decrypted string does not match.
Exceptions
data ClientSessionException Source
Constructors
| KeyTooSmall ByteString | |
| InvalidBase64 String | |
| InvalidHash String | |
| MismatchedHash | |
Fields | |