The Running Key Cipher is a polyalphabetic substitution cipher that uses a long piece of text as the key instead of a short repeating keyword. The key must be at least as long as the plaintext. Each letter of the plaintext is combined with the corresponding letter of the key using modular arithmetic based on the alphabet.
Letters are first converted to numbers using their alphabet positions (A = 0, B = 1, … Z = 25). To encode, the plaintext value and key value are added together and wrapped around using modulo 26. To decode, the key value is subtracted from the ciphertext value.
Running Key Cipher: Encoding
Example: Encode "CAT" using the running key "DOG".
Plaintext: C A T
Key: D O G
Alphabet positions:
C = 2
A = 0
T = 19
D = 3
O = 14
G = 6
Add values (mod 26):
2 + 3 = 5
0 + 14 = 14
19 + 6 = 25
Convert back to letters:
5 → F
14 → O
25 → Z
Ciphertext: FOZRunning Key Cipher: Decoding
To decode, subtract the key value from the ciphertext value (mod 26) and convert the result back to letters.
Ciphertext: F O Z
Key: D O G
Alphabet positions:
F = 5
O = 14
Z = 25
Subtract values (mod 26):
5 - 3 = 2
14 -14 = 0
25 - 6 = 19
Convert back to letters:
2 → C
0 → A
19 → T
Plaintext: CATRunning Key Cipher: Notes
The Running Key Cipher differs from other polyalphabetic ciphers because the key is typically a long piece of natural text such as a book passage or article. Since the key is not repeated like in a Vigenère Cipher, it reduces obvious repeating patterns in the ciphertext.
If the key were truly random and used only once, the system would behave similarly to a one-time pad. However, when natural language is used as the key, statistical patterns remain and can sometimes be exploited by cryptanalysis.