rot26-26: Rot26 cipher

Safe HaskellSafe
LanguageHaskell2010

Rot26

Description

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"

Synopsis

Documentation

type SecretKey = Int Source

Secret key. DO NOT SHARE WITH ANYONE!!

type Plaintext = String Source

Unencrypted data that you don't want other folks to see.

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.