
Since it is even, nothing needs to be added to the end. Now that all pairs are distinct, we check if the length is even or odd. The EE pair is the same so an X is inserted and the letters are rebroken into pairs HI DE TH EG OL DI NT HE TR EX ES TU MP Wikipedia has a visual example of encoding "Hide the gold in the tree stump." Notice how the initial breaking into pairs is HI DE TH EG OL DI NT HE TR EE ST UM P
If a and b are not in the same row or same column, replace them with the letters on the same row respectively but on the other corners of the rectangle defined by the original pair. If a and b are on the same column, replace them with the letters below them, wrapping around if needed. If a and b are on the same row, replace them with letters to their right, wrapping around if needed. Now that all pairs are distinct letters, for each pair (a,b) do the following. If the length is odd and does end with a Z, add a Q on the end. If the length is odd and does not end with a Z, add a Z at the end.
If both letters in a pair are the same and they are X, insert a Q between them and rebreak into pairs. Starting from the left, if both letters in a pair are the same and they are not X, insert an X between them and rebreak into pairs.
Break the input into blocks of two letters. Convert to upper case and remove spaces. Given a table and a message to encrypt, the rules are. (So the first letter entered in the example is B since A has already been used and next comes D.) M A T H E Next, fill in the starred locations with the capital letters in order, skipping the letter J and the letters you have already used. For example, the key word "MATHEMATICS" would produce the table: M A T H E Form the table as follows: given a secret word, first convert any J to an I and then write it letter by letter starting with the top-left and skipping over a letter if you have already written it down. Given a secret word, create a 5 by 5 grid of the 25 capital letters A-Z with J omitted. The rules are listed on Wikipedia, but here they are again with the specific choices we will use. A description of the cipher and a good visual walkthrough is available on Wikipedia.ĭue date is Friday October 30. Project 1 is to implement the encoding and decoding of the Playfair cipher.