Affine Cipher

Affine Cipher encryption and decryption, E(x) = (ax + b) mod 26.

Key Parameters

Valid a values: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25 (coprime to 26)

Encrypt

Decrypt

Substitution Table

Plaintext
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
Ciphertext
I
N
S
X
C
H
M
R
W
B
G
L
Q
V
A
F
K
P
U
Z
E
J
O
T
Y
D

Usage

Algorithm Principle

Affine cipher is a monoalphabetic substitution cipher. Encryption: E(x) = (ax + b) mod 26, Decryption: D(y) = a⁻¹(y - b) mod 26, where a must be coprime to 26.

Parameter Description

Parameter a must be coprime to 26 (1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25), otherwise decryption is impossible; parameter b is the shift, range 0-25.

Limitations

Only processes English letters (a-z, A-Z); non-letter characters remain unchanged. Affine cipher has low security, suitable for educational demonstration only.