Cryptorium

Your Gateway to Cryptographic Mastery

Encrypt


Ensure that a is coprime with 26

Or Upload a File to Encrypt

(Donot support picture encryption)

Decrypt

Or Upload a File to Decrypt

(Donot support picture decryption)

History

Affine Cipher

History

The Affine Cipher is a type of monoalphabetic substitution cipher, which was developed by the French mathematician Étienne Bazeries in the late 19th century. It extends the basic idea of substitution ciphers by incorporating mathematical functions to enhance security. The cipher derives its name from the affine transformation, a type of linear transformation used in mathematics.

Working

The Affine Cipher is based on a mathematical function that combines both a multiplicative and an additive shift to transform each letter in the plaintext. The encryption and decryption processes use modular arithmetic to map letters in a way that the same transformation can be reversed.

Key Concepts

  • Alphabet: Typically, the standard English alphabet of 26 letters is used. Each letter is assigned a number from 0 to 25.
  • Key: The encryption process uses two keys:
    • a is the multiplicative key, which must be coprime with 26 (i.e., gcd(a, 26) = 1).
    • b is the additive key.

Algorithm

Encryption

Key Definition: Choose keys a and b. Ensure that a is coprime with 26.

Encryption Formula:
E(x) = (a ⋅ x + b) mod 26
where x is the numerical value of the plaintext letter (A=0, B=1, ..., Z=25).

Example:

  • Plaintext: HELLO
  • Keys: a = 5, b = 8
  • Conversion of 'H' to a number: 7
  • Encryption of 'H': E(7) = (5 ⋅ 7 + 8) mod 26 = 43 mod 26 = 17
  • 'H' (7) is encrypted to the letter with index 17, which is 'R'.

Decryption

Key Definition: The decryption key a must have an inverse modulo 26. Compute the modular inverse of a, denoted as a-1, such that:
a ⋅ a-1 ≡ 1 mod 26 You can use the Extended Euclidean Algorithm to find a-1.

Decryption Formula:
D(y) = a-1 ⋅ (y - b) mod 26
where y is the numerical value of the ciphertext letter.

Example:

  • Ciphertext: R (17)
  • Keys: a = 5, b = 8
  • Find a-1. For a = 5, a-1 = 21 (since 5 ⋅ 21 ≡ 1 mod 26)
  • Decryption of 'R': D(17) = 21 ⋅ (17 - 8) mod 26 = 21 ⋅ 9 mod 26 = 189 mod 26 = 7
  • 'R' (17) is decrypted to the letter with index 7, which is 'H'.