crypto-classical-0.2.1: An educational tool for studying classical cryptography schemes.

Copyright(c) Colin Woodbury 2015 - 2020
LicenseBSD3
MaintainerColin Woodbury <colin@fosskers.ca>
Safe HaskellNone
LanguageHaskell2010

Crypto.Classical.Cipher.Enigma

Description

 
Synopsis

Documentation

newtype Enigma a Source #

Constructors

Enigma 

Fields

Instances
Monad Enigma Source # 
Instance details

Defined in Crypto.Classical.Cipher.Enigma

Methods

(>>=) :: Enigma a -> (a -> Enigma b) -> Enigma b #

(>>) :: Enigma a -> Enigma b -> Enigma b #

return :: a -> Enigma a #

fail :: String -> Enigma a #

Functor Enigma Source # 
Instance details

Defined in Crypto.Classical.Cipher.Enigma

Methods

fmap :: (a -> b) -> Enigma a -> Enigma b #

(<$) :: a -> Enigma b -> Enigma a #

Applicative Enigma Source # 
Instance details

Defined in Crypto.Classical.Cipher.Enigma

Methods

pure :: a -> Enigma a #

(<*>) :: Enigma (a -> b) -> Enigma a -> Enigma b #

liftA2 :: (a -> b -> c) -> Enigma a -> Enigma b -> Enigma c #

(*>) :: Enigma a -> Enigma b -> Enigma b #

(<*) :: Enigma a -> Enigma b -> Enigma a #

Cipher EnigmaKey Enigma Source #

When a machine operator presses a key, the Rotors rotate. A circuit is then completed as they hold the key down, and a bulb is lit. Here, we make sure to rotate the Rotors before encrypting the character. NOTE: Decryption is the same as encryption.

Instance details

Defined in Crypto.Classical.Cipher.Enigma

Eq a => Eq (Enigma a) Source # 
Instance details

Defined in Crypto.Classical.Cipher.Enigma

Methods

(==) :: Enigma a -> Enigma a -> Bool #

(/=) :: Enigma a -> Enigma a -> Bool #

Show a => Show (Enigma a) Source # 
Instance details

Defined in Crypto.Classical.Cipher.Enigma

Methods

showsPrec :: Int -> Enigma a -> ShowS #

show :: Enigma a -> String #

showList :: [Enigma a] -> ShowS #

enigma :: forall a a. Lens (Enigma a) (Enigma a) a a Source #

withInitPositions :: EnigmaKey -> EnigmaKey Source #

Applies the initial Rotor settings as defined in the Key to the Rotors themselves. These initial rotations do not trigger the turnover of neighbouring Rotors as usual.

turn :: [Rotor] -> [Rotor] Source #

Turn the (machine's) right-most (left-most in List) Rotor by one position. If its turnover value wraps back to 25, then turn the next Rotor as well.

rotate :: ( / 26) -> Map ( / 26) ( / 26) -> Map ( / 26) ( / 26) Source #

Rotate a Rotor by n positions. By subtracting 1 from every key and value, we perfectly simulate rotation. Example:

>>> rotate $ M.fromList [(0,2),(1,0),(2,3),(3,4),(4,1)]
M.fromList [(4,1),(0,4),(1,2),(2,3),(3,0)]