Description
C++
implement a program to encrypt messages.
The idea is very simple. Every letter of the alphabet will be substituted with some other letter according to a given key pattern like the one below.
“abcdefghijklmnopqrstuvwxyz”
“doxrhvauspntbcmqlfgwijezky” // key pattern
For example, every ‘a’ will become a ‘d’ and every ‘k’ will become a ‘n’. Upper case letters are encoded the same way but they remain upper case (e.g. every ‘A’ will become a ‘D’), while any characters which are not letters of the alphabet (e.g.: digits, space, punctuation, etc) remain as given (e.g. every ‘1’ remains a ‘1’). The process is symmetrical so decoding of an encoded text can be done using the corresponding decoding key pattern.
Part 1: implement a simple encoder class which encodes strings based on a key pattern. The class has a single public function to encode a string since decoding can be done using a new encoder constructed with the symmetrical decoding key pattern.
Part 2: Improve the program.include common abbreviations like ‘LOL” when the messeges are sent. not allowing people to figure out the whole scheme once they notice “TMT” appearing so often in the logs.
Plan to implement a new encoder which is based on the previous one but which has the ability to pad each character with a fixed number of random letters/digits. For example, with a padding of 3, “LOL” would be encoded to a word like T###M###T### where the # are random chars from the set [a-z, A-Z, 0-9], for example TabiM8rcTyFp or ThV9MbolTJDj, each time appearing different.
The padding encoder has a new function used to decode which removes the junk characters from the encrypted texts. This way LOL can be retrieved from both TabiM8rcTyFp and ThV9MbolTJDj since LabiO8rcLyFp and LhV9ObolLJDj are not very funny.
A starter file has been given here project4_first_last.cpp
A sample output of the program for the string “Hello class!” is given below:
Encoded: Uhttm xtdgg!
Decoded: Hello class!
Pad Encoded: UfTohAlrty44tqiTm2OG 95Kx3zgtrNQd1GrgD5PgKQu!koU
Pad Decoded: Hello class!
#include