Playfair Cipher

PLAYFAIR CIPHER

The best-known multiple-letter encryption cipher is the Playfair, which treats digrams in the plaintext as single units and translates these units into ciphertext digrams.

The Playfair algorithm is based on the use of a 5 * 5 matrix of letters constructed using a keyword.

1. Repeating plaintext letters that are in the same pair are separated with a filler letter, such as x, so that balloon would be treated as ba lx lo on.

2. Two plaintext letters that fall in the same row of the matrix are each replaced by the letter to the right, with the first element of the row circularly following the last.

3. Two plaintext letters that fall in the same column are each replaced by the letter beneath, with the top element of the column circularly following the last.

4. Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row and the column occupied by the other plaintext letter.

1. Key Generation:
- Generate a key table using the keyword "KEYWORD," excluding duplicate letters and adding the rest of the alphabet (excluding "J").

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

2. Message Preparation:
- Prepare the message "HELLO" for encryption, pairing letters and inserting a filler ("X" in this case).
Prepared Message: H E L X L O

3. Encryption:
- Apply Playfair rules to encrypt the prepared message:

Encrypted Message: LOMXHE