Consider the following rudimentary encryption system.
For a given ordered alphabet, such as < ‘a’, ‘b’, ‘c’, ‘ ’, ‘0’, ‘1’ >, we can scramble the characters randomly so that they are ordered differently. For example, the previous alphabet may become < ‘c’, ‘0’, ‘ ’, ‘a’, ‘1’, ‘b’ >. These two ordered alphabets provide us with one-to-one mapping of the characters. Using this mapping, we can encrypt and decrypt any word or sentence made up from the characters of the alphabet. For example, the word “bac” is coded as “0c ”. Using the same mapping, we can decrypt the code “0c ” back to its clear text “bac”.
Design, write in Java, test and document a program to implement an encryption system described above. Your system must handle a larger alphabet consisting of 26 upper case letters, the ten digits, the three punctuation marks ‘.’ (full stop), ‘,’ (comma), and ‘!’ (exclamation mark) as well as the space character ‘ ’. All together there should be 40 characters in this alphabet.
At the beginning, your program should ask the user to specify a one-to-one mapping between the characters in the above mentioned alphabet. For example, your program may display the 40 characters in one line and ask the user to type the same set of characters in the second line, but in a different order. After the mapping is established, your program should then ask the user to type in a sentence using the characters from this alphab, and then output the encrypted sentence.
The program should loop around until the user does not want to enter any more sentences for encryption Note that your program should be able to decrypt the code of a previously encrypted sentence, as the mapping is symmetrical
Your program must check to make sure that the mapping specified by the user is indeed a one-to-one mapping. Otherwise, the encryption/decryption would not work correctly. Similarly, you should check each user sentence to make sure that it only consists of characters from the selected alphabet (26 upper case letters, the ten digits, the three punctuation symbols described above, and the space character). In addition, you should design a sensible way for the user to signal the end of the program. The program should be well-structured and should have a reasonable set of methods in addition to the main method. It should use a good coding style, proper indentation, meaningful identifiers and appropriate comments throughout.