!|t      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` a b c d e f g h i j k l m n o p q r s (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>Safecrypto-classicalA  is a capital Ascii letter (A-Z)(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None.UVycrypto-classical(Must be passed a number coprime with 26. crypto-classical|The sequence (r1,...r[n-1]) of numbers such that r[i] is an independent sample from a uniform random distribution [0..n-i] crypto-classical~Invert a Map. Keys become values, values become keys. Note that this operation may result in a smaller Map than the original. crypto-classicalCompose two Maps. If some key v( isn't present in the second Map, then k will be left out of the result.Q2015 April 16 @ 13:56 Would it be possible to make a Category for Map like this? crypto-classical*An alias for compose. Works left-to-right. crypto-classicalHZip a list on itself. Takes pairs of values and forms a tuple. Example:uniZip [1,2,3,4,5,6][(1,2),(3,4),(5,6)]crypto-classicalZStretch the contents of a list. List becomes twice a long. List must be finite. Example:stretch [1,2,3,4][1,1,2,2,3,3,4,4]    (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>Nonefcrypto-classicalGiven a sequence (e1,...en) to shuffle, its length, and a random generator, compute the corresponding permutation of the input sequence.tcrypto-classicalGiven a sequence (e1,...en) to shuffle, and a sequence (r1,...r[n-1]) of numbers such that r[i] is an independent sample from a uniform random distribution [0..n-i], compute the corresponding permutation of the input sequence.(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None .=?@ACUVMcrypto-classicalA Rotor (German: Walze) is a wheel labelled A to Z, with internal wirings from each entry point to exit point. There is also a turnover point, upon which a Rotor would turn its left neighbour as well. Typically said turnover point is thought of in terms of letters (e.g. Q->R for Rotor I). Here, we represent the turnover point as a distance from A (or 0, the first entry point). As the Rotor rotates, this value decrements. When it rolls back to 25 (modular arithmetic), we rotate the next Rotor.Our Rotors are letter-agnostic. That is, they only map numeric entry points to exit points. This allows us to simulate rotation very simply with Lenses.crypto-classicalKeys can appear in a number of different forms. E.g. a single number, a tuple, a mapping, etc. Each needs to be interpreted uniquely by a Cipher's  and  algorithms.crypto-classicalRandomly generate a Key.crypto-classicalWA Cipher must be able to encrypt and decrypt. The Cipher type determines the Key type.crypto-classicalKey for Stream/Vigenre Cipher.crypto-classical;Key for Substitution Cipher. The Key is the Mapping itself.crypto-classicalFor Affine Ciphers. aM must be coprime with 26, or else a^-1 won't exist and and we can't decrypt.!crypto-classicalEssentially the machine itself. It is made up of: 1. Three rotor choices from five, in a random placement. 2. Initial settings of those Rotors. 3. The Reflector model in use. 4. Plugboard settings (pairs of characters).'crypto-classicalA set of 10 pairs of connected letters which would map letters to other ones both before and after being put through the Rotors. The remaining six unpaired letters can be thought of mapping to themselves.(crypto-classicalLA unmoving map, similar to the Rotors, which feeds the electrical current back into Rotors. This would never feed the left Rotor's letter back to itself, meaning a plaintext character would never encrypt to itself. This was a major weakness in scheme which allowed the Allies to make Known Plaintext Attacks against the machine.ucrypto-classicalRotor I: Turnover from Q to R.vcrypto-classicalRotor II: Turnover from E to F.wcrypto-classical Rotor III: Turnover from V to W.xcrypto-classicalRotor IV: Turnover from J to K.ycrypto-classicalRotor V: Turnover from Z to A.zcrypto-classical/Generate random start positions for the Rotors.{crypto-classicalGenerate settings for the Plugboard. Ten pairs of characters will be mapped to each other, and the remaining six characters will map to themselves.2crypto-classicalyGiven a list of letter pairs, generates a Plugboard. Any letters left out of the pair list will be mapped to themselves.3crypto-classicalNote that the randomly generated initial Rotor positions are not applied to the Rotors when the key is generated. They have to be applied before first use.!"#$%&'()*+./012!"#$%&('*+)01/.2(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None4=?@ARi4crypto-classicalqA Cipher whose key is a (pseudo)random mapping of characters to other characters. A character may map to itself.456:456:(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None .4=?@AUVX>crypto-classicalA Cipher with pseudorandom keys as long as the plaintext. Since Haskell is lazy, our keys here are actually of infinite length.:If for whatever reason a key of finite length is given to =, the ciphertext is cutoff to match the key length. Example:"encrypt [1,2,3] "ABCDEF" ^. stream"BDF">?@D>?@D(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None .4=?@AUVk_Hcrypto-classicalA Vigenre Cipher is just a Stream Cipher with a finite key, shorter than the length of the plaintext. The key is repeated for the entire length of the plaintext.Ocrypto-classicalkDetermine a Vigenre key from a Stream key. Weakness here: key length is a factor of the plaintext length.HIJNOHIJNO(c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None.4@AUVnZcrypto-classicalApplies 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.[crypto-classicalTurn 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.\crypto-classicalRotate a Rotor by n` positions. By subtracting 1 from every key and value, we perfectly simulate rotation. Example:3rotate $ M.fromList [(0,2),(1,0),(2,3),(3,4),(4,1)]*M.fromList [(4,1),(0,4),(1,2),(2,3),(3,0)]]crypto-classicalWhen 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.STUYZ[\STUYZ[\ (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None .4=?@AUVs`crypto-classicalcA simple Shift Cipher. The key is a number by which to shift each letter in the alphabet. Example:0encrypt 3 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ^. caesar"DEFGHIJKLMNOPQRSTUVWXYZABC"`abf`abf (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None .4=?@AUVxjcrypto-classicalMAn Affine Cipher is a non-random Substitution Cipher, such that a character x; is mapped to a cipher character according to the equation:f(x) = ax + b (mod 26)Also known as a Linear Cipher.jklpjklp (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>Nonez456:>?@DHIJNOSTUYZ[\`abfjklp (c) Colin Woodbury, 2015 - 2020BSD3"Colin Woodbury <colin@fosskers.ca>None{D !"#$%&'()*+./012456:>?@DHIJNOSTUYZ[\`abfjklp|   !"#$%&'()*+,,-./0123456789:;<=>>?@ABCDEFGGHIJKLMNOPPQRSTUVWXYZZ[\]^_`abcde f f g h i j k l m n o o p q r s t u v wxyz{|}~-crypto-classical-0.2.1-DirCGfxmm6x4zySOEfYaZ2Crypto.Classical.LetterCrypto.Classical.UtilCrypto.Classical.ShuffleCrypto.Classical.Types$Crypto.Classical.Cipher.SubstitutionCrypto.Classical.Cipher.Stream Crypto.Classical.Cipher.VigenereCrypto.Classical.Cipher.EnigmaCrypto.Classical.Cipher.CaesarCrypto.Classical.Cipher.AffineCrypto.Classical.CipherCrypto.ClassicalLetter_char $fEqLetter $fShowLetterletterintinverseprngrseq mapInversecompose|.|uniZipstretchshuffle $fShowTreeRotor_name _turnover_circuitKeykeyCipherencryptdecrypt$fKey[]$fKeyMap$fKey(,)$fKeyMod $fEqRotor $fShowRotor EnigmaKey_rotors _settings _reflector _plugboard Plugboard Reflectorcircuitnameturnover $fEqEnigmaKey$fShowEnigmaKey plugboard reflectorrotorssettingsplugFrom$fKeyEnigmaKey Substitution _substitution$fEqSubstitution$fShowSubstitution$fFunctorSubstitution substitution$fCipherMapSubstitution$fMonadSubstitution$fApplicativeSubstitutionStream_stream $fEqStream $fShowStream$fFunctorStreamstream$fCipher[]Stream $fMonadStream$fApplicativeStream Vigenère _vigenère $fEqVigenère$fShowVigenère$fFunctorVigenère vigenèrevigKey$fCipher[]Vigenère$fMonadVigenère$fApplicativeVigenèreEnigma_enigma $fEqEnigma $fShowEnigma$fFunctorEnigmaenigmawithInitPositionsturnrotate$fCipherEnigmaKeyEnigma $fMonadEnigma$fApplicativeEnigmaCaesar_caesar $fEqCaesar $fShowCaesar$fFunctorCaesarcaesar$fCipherModCaesar $fMonadCaesar$fApplicativeCaesarAffine_affine $fEqAffine $fShowAffine$fFunctorAffineaffine$fCipher(,)Affine $fMonadAffine$fApplicativeAffineshuffle'rIrIIrIIIrIVrV randCharsrandPlug