Question: Here is the header code: #ifndef PROJ05_FOURSQUARE #define PROJ05_FOURSQUARE #include using std:: string; string clean_string(string s); string create_encoding(string key); string encode_digraph(string dg, string block1, string



Here is the header code:
#ifndef PROJ05_FOURSQUARE #define PROJ05_FOURSQUARE #includeusing std:: string; string clean_string(string s); string create_encoding(string key); string encode_digraph(string dg, string block1, string block2); string decode_digraph(string dg, string block1, string block2); string encode(string msg, string key1, string key2); string decode(string msg, string key1, string key2); #endif
Keywords Block 1 represents an encoding of the keyword "example". The letters are enumerated, starting with the keyword, so that only 1 occurrence of each letter is represented. Thus, the first letters in Block 1 are "exampl" (note the last 'e' is not included, it is already in the block). Subsequently all the letters that are not represented are place in the block in alphabetical order! The same is then done for Block 2 using the keyword "keyword". Encoding Encoding uses the 4 blocks to encode a message in groups of two characters. Note that the underlying message is assumed to have an even number of letters, and if not the letter 'x' is added arbitrarily at the end of the message. Let's encode (as the Wikipedia does) "Hello World!" First, we process the message so that it consists of only alphabetic, lower case letters. Thus we will actually be encoding "helloworld". Done in pairs, the first digraph (an example of two letters) is "he". Lets encode that: 0 0 1 2 3 4 0 1 2 34 0 1 2 3 4 0 1 2 3 4 We look up the two letters of "he", the first, 'h', in Block 0 and the second, 'e' in Block 2. We use their location as a way to access letters in the same row and column in Blocks 1 and 3. The 'h' and 'e' point to 'f in Block 1 and 'y' in Block 3. The first two letters are therefore encoded as 'fy' in that order. Keep repeating that process for every pair of letters in the message, you get: "fyhghzhsje". Follow the blue arrows for encoding Keywords Block 1 represents an encoding of the keyword "example". The letters are enumerated, starting with the keyword, so that only 1 occurrence of each letter is represented. Thus, the first letters in Block 1 are "exampl" (note the last 'e' is not included, it is already in the block). Subsequently all the letters that are not represented are place in the block in alphabetical order! The same is then done for Block 2 using the keyword "keyword". Encoding Encoding uses the 4 blocks to encode a message in groups of two characters. Note that the underlying message is assumed to have an even number of letters, and if not the letter 'x' is added arbitrarily at the end of the message. Let's encode (as the Wikipedia does) "Hello World!" First, we process the message so that it consists of only alphabetic, lower case letters. Thus we will actually be encoding "helloworld". Done in pairs, the first digraph (an example of two letters) is "he". Lets encode that: 0 0 1 2 3 4 0 1 2 34 0 1 2 3 4 0 1 2 3 4 We look up the two letters of "he", the first, 'h', in Block 0 and the second, 'e' in Block 2. We use their location as a way to access letters in the same row and column in Blocks 1 and 3. The 'h' and 'e' point to 'f in Block 1 and 'y' in Block 3. The first two letters are therefore encoded as 'fy' in that order. Keep repeating that process for every pair of letters in the message, you get: "fyhghzhsje". Follow the blue arrows for encoding
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
