CSC327 · 2082 · 5 marks
Given the key "HELLOWORLD", encrypt the plaintext "TURINGTEST" using Play fair cipher.
Given the key "HELLOWORLD", encrypt the plaintext "TURINGTEST" using Play fair cipher. [5]
Playfair Cipher: Encrypting "TURINGTEST" with Key "HELLOWORLD"
Given
- Key: HELLOWORLD
- Plaintext: TURINGTEST
- Cipher: Playfair (5x5 matrix, I/J combined)
Solution
Build the 5x5 Matrix
Key letters, removing duplicates (keep first occurrence): H, E, L, O, W, R, D (HELLOWORLD → H, E, L, [L dup], O, W, [O dup], R, [L dup], D)
Fill remaining alphabet (I/J together): A, B, C, F, G, I/J, K, M, N, P, Q, S, T, U, V, X, Y, Z
| C1 | C2 | C3 | C4 | C5 | |
|---|---|---|---|---|---|
| R1 | H | E | L | O | W |
| R2 | R | D | A | B | C |
| R3 | F | G | I/J | K | M |
| R4 | N | P | Q | S | T |
| R5 | U | V | X | Y | Z |
Split into digrams
TURINGTEST → TU | RI | NG | TE | ST
No double letters within a pair, length is even, so no padding needed.
Apply rules
TU: T(R4,C5), U(R5,C1) → rectangle T → (R4, C1) = N; U → (R5, C5) = Z → NZ
RI: R(R2,C1), I(R3,C3) → rectangle R → (R2, C3) = A; I → (R3, C1) = F → AF
NG: N(R4,C1), G(R3,C2) → rectangle N → (R4, C2) = P; G → (R3, C1) = F → PF
TE: T(R4,C5), E(R1,C2) → rectangle T → (R4, C2) = P; E → (R1, C5) = W → PW
ST: S(R4,C4), T(R4,C5) → same row (shift right, wrap) S → C5 = T; T → C1 (wrap) = N → TN
Final Ciphertext
| Plain pair | Cipher pair |
|---|---|
| TU | NZ |
| RI | AF |
| NG | PF |
| TE | PW |
| ST | TN |
$$\boxed{\text{Ciphertext} = \text{NZAFPFPWTN}}$$
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.