Home Shift Cipher Substitution Cipher Affine Cipher Hill Cipher Permutation Cipher Vernam Cipher

About Affine-cipher


The Affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter.
The formula used means that each letter encrypts to one other letter, and back again, meaning the cipher is essentially a standard substitution cipher with a rule governing which letter goes to which.
The ‘key’ for the Affine cipher consists of 2 numbers, we’ll call them a and b. The following discussion assumes the use of a 26 character alphabet (m = 26). a should be chosen to be relatively prime to m (i.e. a should have no factors in common with m).
Affine-cipher has 312 possibe keys. Its found out by 26 * euler's phi(26). The attack method used to cryptanalyze the cryptosystem is Exhaustive search or frequency analysis.
The attack model used is cipher-text only. The cryptosystem is not secure.

Encryption:

E ( x ) = ( a x + b ) mod m modulus m: size of the alphabet
a and b: key of the cipher.
a must be chosen such that a and m are coprime.

Decryption:

D ( x ) = a^-1 ( x - b ) mod m
a^-1 : modular multiplicative inverse of a modulo m.
i.e., it satisfies the equation 1 = a a^-1 mod m .


Encrypt
Decrypt