IVX
로마 숫자 변환기KO
CLASSICAL SUBSTITUTION & TRANSPOSITION CIPHERS TOOL • UNIFIED WORKSPACE

Affine Cipher

Encrypt and solve monoalphabetic substitution ciphers using mathematical linear functions E(x) = (ax + b) mod 26 with custom slope and shift keys.

Presets:
Ready
MMXXVI
복사됨!

상세 계산 과정

Affine Cipher 소개 및 원리

The Affine cipher is a monoalphabetic substitution cipher that maps each letter to its numeric equivalent, applies a mathematical linear congruence function, and converts the resulting integer back to a letter.

Unlike the Caesar cipher (which only adds a shift $b$), the Affine cipher introduces a multiplication factor $a$ (called the slope or multiplier): $E(x) = (a \cdot x + b) \pmod{26}$. For the cipher to be invertible, the multiplier $a$ must be coprime to 26 (meaning $\gcd(a, 26) = 1$).

There are exactly 12 valid multipliers coprime to 26 (1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25), providing a key space of $12 \times 26 = 312$ distinct cipher variations.

도구 사용 방법

  1. 입력 필드에 변환할 값 또는 텍스트를 입력합니다.
  2. 필요에 따라 변환 옵션 및 방향을 설정합니다.
  3. 변환 결과가 실시간으로 즉시 생성됩니다.
  4. 복사 버튼을 클릭하여 결과를 클립보드에 복사합니다.

Mathematical Formulas for Affine Cipher

Encryption: $C = (a \cdot P + b) \pmod{26}$

Decryption: $P = a^{-1} \cdot (C - b) \pmod{26}$, where $a^{-1}$ is the modular multiplicative inverse of $a$ modulo 26 such that $(a \cdot a^{-1}) \equiv 1 \pmod{26}$.

Affine Cipher Examples

Encryption with a=5, b=8

Encrypting "AFFINE CIPHER" with linear keys a=5, b=8.

In:AFFINE CIPHER (a=5, b=8)
Out:IHHWVC CWXHCP

Decryption with Modular Inverse

Deciphering "IHHWVC CWXHCP" using modular inverse $a^{-1} = 21$.

In:IHHWVC CWXHCP
Out:AFFINE CIPHER

Coprime Key Requirement

  • The multiplier $a$ must share no common factors with 26. Even numbers (2, 4, 6...) and 13 are invalid keys because they do not have a modular inverse.

자주 묻는 질문

What is the Affine cipher?
The Affine cipher is a mathematical substitution cipher where each letter's index $x$ is mapped to $(a \cdot x + b) \pmod{26}$ using two secret keys $a$ and $b$.
Why must the key "a" be coprime to 26?
If $\gcd(a, 26) \ne 1$, different plaintext letters would map to the exact same ciphertext letter, making unambiguous decryption impossible.
How many total keys does the Affine cipher have?
There are 12 valid values for $a$ and 26 possible values for $b$, giving $12 \times 26 = 312$ possible keys.

관련 도구