Playfair Cipher Simulator
Investigate the logic of the Playfair Cipher and experiment with different keys and plaintexts to observe how letter pairs are encrypted and decrypted using our interactive simulator.
Playfair Cipher
Cryptography shapes the way we protect information every day, often in ways we hardly notice. Have you ever wondered how messages were secretly exchanged long before digital encryption existed? One of the most ingenious methods from that era is the Playfair Cipher, a technique that encrypts pairs of letters instead of single ones to make decoding far more challenging. With our interactive simulator, you can explore this clever cipher hands-on — create custom keys, encode and decode messages, and uncover the logic behind its matrix-based encryption. Step into the fascinating world of classical cryptography — experiment with the Playfair Cipher today!
Mathematical description
- Construct the 5×5 key matrix M using a chosen keyword.
\[
M =
\begin{bmatrix}
m_{11} & m_{12} & m_{13} & m_{14} & m_{15} \\
m_{21} & m_{22} & m_{23} & m_{24} & m_{25} \\
m_{31} & m_{32} & m_{33} & m_{34} & m_{35} \\
m_{41} & m_{42} & m_{43} & m_{44} & m_{45} \\
m_{51} & m_{52} & m_{53} & m_{54} & m_{55}
\end{bmatrix}
\] - Divide the plaintext into pairs of letters (digraphs):
\[
P = \{ (p_1, p_2), (p_3, p_4), \dots, (p_{n-1}, p_n) \}
\] - For each digraph (a, b), locate their positions }
(a_i, a_j) and (b_i, b_j) in M.
Encryption rules:
\begin{cases}
a’ = m_{i, (j+1) \bmod 5}, \quad b’ = m_{i, (j+1) \bmod 5}, & \text{if in same row} \\
a’ = m_{(i+1) \bmod 5, j}, \quad b’ = m_{(i+1) \bmod 5, j}, & \text{if in same column} \\
a’ = m_{i, b_j}, \quad b’ = m_{b_i, a_j}, & \text{if forming a rectangle}
\end{cases}
The ciphertext C is the sequence of all resulting digraphs:
\[
C = \{ (a’_1, b’_1), (a’_2, b’_2), \dots, (a’_n, b’_n) \}
\]
Example:
Keyword: MONARCHY
Plaintext: INSTRUMENTS
After processing digraphs: (IN)(ST)(RU)(ME)(NT)(SX)
Ciphertext: GATLMZCLRQTX