This exercise will implement a ciphering or cryptographic algorithm. Algorithms
ID: 3763900 • Letter: T
Question
This exercise will implement a ciphering or cryptographic algorithm. Algorithms like this are used for rendering written messages unreadable, at least without some difficulty, except by those who are possession of “secret” information. The secret information is generally referred to as the “key”. Making text difficult to read is called enciphering or encrypting. Using the secret key to read the enciphered message is called deciphering or decrypting. The unencrypted message is called cleartext or plaintext. The encrypted message is called cryptext or ciphertext. The idea for this particular algorithm is said to have been due to Julius Caesar so he could send secret messages to his military commanders. Consequently, the algorithm is called a “Caesar” cipher. Actually, Caesar cipher is weaker than what you will implement here. To begin, we need an alphabet. This is a collection of letters, punctuation characters and any other characters that are allowed to be writing of a cleartext message. These same characters will also be used to construct the ciphertext, but the characters will be randomly scrambled. The scrambled alphabet with be out secret key. Here is an example: Alphabet = abcdefghijklmnopqrstuvwxyz Key = tslauepmfqirzcxdogyhvbnwj Notice that the key contains exactly the same characters as the alphabet does, neither more nor less. The key is simply a re-ordering of the alphabet, Now, let’s use the key to encrpt a simple cleartext message constructed from the alphabet. Cleartext = shortmessage Cryptext = ymxghzuyytpu Note how the crypt message is constructed. Imagine the alphabet and the key are stored in arrays. We find the index, 18, of the first cleartext character (‘s’ in the alphabet). Then we create the cryptext character “y’ by using the character with index 18 in the key array. For each character in the cleartext: Find the index i, of the character in the alphabet Use that same index to get the corresponding character from the key Use that character for the one in the cleartext. Now, to decrypt the cryptext and recover the cleartext, we use exactly the same process as that used above. But, we decrypt by encrypting the cryptext. And we use the key array for our alphabet and the alphabet array for our key. Another thing to note is our alphabet can consist of any legitimate characters, including the space, character, uppercase, lowercase and punctuation characters. What happens if we encounter a character not in the alphabet, simply print a message to the screen. Your task is to implement this algorithm using an object-oriented design. Then allow the user to enter cleartext messages to encrypt and encrypted messages to decipher.
Explanation / Answer
Question is not understanding
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.