Playfair Cipher
Digraph substitution cipher
Encrypts a pair of alphabets (digraphs) instead of a single alphabet
Algorithm Steps
Generate they key square (5x5)
5x5 grid of alphabets (25)
Each character must be unique
B.c. there are 26 characters, one of them will be omitted (usually "j")
If "j" appears, it is replaced with "i"
The initial alphabets in the key square are the unique alphabets of the key in the order in which they appear followed by the remaining letters of the alphabet in order
Algorithm to encrypt the plain text:
Plaintext is split into two letters (digraphs)
If odd number of letters, a "Z" is added to last letter
Worked example: "instruments"
"in", "st", "ru", "me", "nt", "sz"
A pair cannot be made with the same same letter
Break the pair & add a bogus letter
"hello"
"he", "ll", "ox"
"he", "lx", "lo"
Rules for encryption
If both the letters aer in the same column Take the letter below each one (going back to the top if at them bottom)
If both the letters are in the same row Take the letter to the right of each one (going back to the leftmost if at the rightmost position)
If neither of the above rules is true Form a rectangle with the two letters and take the letters on the horizontal opposite corner of the rectangle
The process of decryption is just doing the reverse, simple as that!

模拟退火算法 (Simulated annealing) & 爬山算法(Hill-climbing)

Last updated