Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Implements the Rot26 cipher.
Contrary to popular belief, implementing Rot26 is far from an easy task (it takes at least two dozen lines of Haskell code). One needs to take into account the possibility of side-channel attacks by an oracle while also ensuring that the encryption key is generated via a perfect random number generator. Fortunately, this library takes care of all those icky details.
The library is very easy to use. Here is a basic example:
import Rot26 main = do let secretKey = generateSecretKey let ciphertext = encrypt secretKey "Hello world" let plaintext = decrypt secretKey ciphertext putStrLn plaintext -- this should say "Hello world"
- type SecretKey = Int
- type Plaintext = String
- type Ciphertext = String
- generateSecretKey :: SecretKey
- encrypt :: SecretKey -> Plaintext -> Ciphertext
- decrypt :: SecretKey -> Ciphertext -> Plaintext
Documentation
type Ciphertext = String Source
Encrypted data. No-one can figure out what's in there.
generateSecretKey :: SecretKey Source
Generate a secret key with maximum entropy.
encrypt :: SecretKey -> Plaintext -> Ciphertext Source
Encrypt your secret data using the Rot26 cipher.
decrypt :: SecretKey -> Ciphertext -> Plaintext Source
Decrypt your secret data using the Rot26 cipher.