trevorswann / CipherTool

Command line cipher tool for encoding and decoding text with different types of ciphers.
MIT License
1 stars 0 forks source link

Playfair Cipher #7

Open trevorswann opened 3 years ago

trevorswann commented 3 years ago

Add in functionality for Playfair cipher. Uses a 5x5 matrix to encipher text from pairs of plaintext letters into pairs of cipher text letters. Arrangement of alphabet in 5x5 grid is determined by keyword. Begin writing the keyword horizontally along the first row, moving to the second row, and so on. Do NOT write any duplicate letters. Once the keyword has been written in, fill remaining spaces with remaining letters in alphabetic order, again, no duplicates. Being that there will only be 25 spaces, put 'i' and 'j' in the same box. If the plaintext has repeated letters that would fall within the same pair (like the 2 'T's in 'LETTERS') then add a random letter in between. ex: 'LE' 'TX' 'TE' 'RS'. If you get to the end of the plaintext and the last letter to encrypt doesn't have another letter to pair with, add a random letter onto the end.

5x5 grid example with keyword "PLAYFAIR"

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