Affine Cipher
Yaser Rahmati | یاسر رحمتی
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.
How the Affine Cipher Works
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:
Example: Encrypting the Word "HELLO"
1. Choose keys a and b:
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.
2. Convert each letter of "HELLO" to its numerical equivalent:
H = 7, E = 4, L = 11, L = 11, O = 14.
3. Apply the encryption formula:
For H:
For E:
For L:
For L:
For O:
The ciphertext for "HELLO" is "RCLLA".
Decrypting the Ciphertext "RCLLA"
1. Find the modular inverse of 𝑎 = 5 modulo 𝑚 = 26
By trial or using the Extended Euclidean Algorithm:
2. Convert each letter of "RCLLA" back to its numerical equivalent:
R = 17, C = 2, L = 11, L = 11, A = 0.
3. Apply the decryption formula:
For R:
For C:
For L:
For L:
For A:
4. The decrypted plaintext is "HELLO".
Summary
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.
Keywords
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
, یاسر رحمتی
External Links
🌐 Personal Website 📄 Resume 🎥 Video Archive 💼 Finance Blog 🔐 Network & Security Notebook 🎬 Aparat Channel
Last updated