Affine Cipher
Yaser Rahmati | یاسر رحمتی
Last updated
Yaser Rahmati | یاسر رحمتی
Last updated
The Affine Cipher is a type of monoalphabetic substitution cipher, which means each letter in the plaintext is mapped to a single corresponding letter in the ciphertext. The Affine Cipher combines both the Caesar Cipher and Multiplicative Cipher to create a more complex encryption method.
The encryption process for the Affine Cipher is a function that maps a letter x (where x is the position of the letter in the alphabet, starting with 0 for 'A') to a letter y using the formula:
Here:
y is the encrypted letter.
a and b are keys used in the cipher.
m is the size of the alphabet (for English, m=26).
x is the position of the plaintext letter in the alphabet.
To decrypt, you use the inverse of the function:
where:
Let a=5 and b=8.
Check that a and m=26 are coprime (i.e., they have no common divisors other than 1). For this example, 5 and 26 are coprime, so we can use 5 as a.
H = 7, E = 4, L = 11, L = 11, O = 14.
For H:
For E:
For L:
For L:
For O:
The ciphertext for "HELLO" is "RCLLA".
By trial or using the Extended Euclidean Algorithm:
R = 17, C = 2, L = 11, L = 11, A = 0.
For R:
For C:
For L:
For L:
For A:
The Affine Cipher encryption is more secure than the Caesar Cipher because it adds both multiplication and addition, making it harder to break without knowing both keys. However, it is still vulnerable to frequency analysis because it is a substitution cipher.
Affine Cipher
, encryption
, decryption
, monoalphabetic
, substitution cipher
, plaintext
, ciphertext
, Caesar Cipher
, Multiplicative Cipher
, modular arithmetic
, coprime, keys
, alphabet
, modulo
, encryption formula
, decryption formula
, modular inverse
, cryptography
, security
, key space
, frequency analysis
, multiplicative key
, additive key
, cryptographic algorithm
, affine transformation
, letter mapping
, numerical equivalent
, affine function
, Euclidean algorithm
, Extended Euclidean Algorithm
, modular multiplicative inverse
, cipher text
, letter positions
, mathematical function
, alphabet size
, modular reduction
, brute-force attack
, computational complexity
, modular operations
, inverse calculation
, cipher keys
, cryptanalysis
, encryption process
, plaintext conversion
, inverse function
, mathematical encryption
, alphabetic encryption
, substitution technique
, modular system
, Yaser Rahmati
, یاسر رحمتی
🌐 Personal Website 📄 Resume 🎥 Video Archive 💼 Finance Blog 🔐 Network & Security Notebook 🎬 Aparat Channel