Question
Vigenre Cipher c++ To encrypt a single letter, we take the plaintext letter and corresponding letter of the key and add them together. To add
Vigenre Cipher c++
To encrypt a single letter, we take the plaintext letter and corresponding letter of the key and add them together. To add a letter means that we first consider the letters as numbers, add the two numbers, and translate back to letters. So for example, if we had the plaintext letter 'B' and the key letter 'C', we translate this to 1 and 2 based on their position in alphabetic order. Add them to get 3, which corresponds to the letter 'D'. To deal with the situation of the sum exceeding 26, we simply take the sum modulo 26. That is if the plaintext letter is 'Z' and the key is 'B', this becomes 25 + 1, or 0 mod 26 and thus is the ciphertext letter 'A'.
You will need to write a program to implement the Vigenre cipher. In the end, your program should do the following:
- Open a file and read it in as a string.
- Prompt the user for a key.
- Encrypt the file with the key and write it out to a temporary file.
- Open the temporary file and read it in as a string.
- Decrypt the file.
- Verify that the plaintext and decrypted ciphertext match.
As part of this process you need to develop functions and classes, as appropriate, using the techniques we have developed in lecture. In particular you should utilize operator overloading during the encryption process. That is as part of your encryption process you should have a line roughly looking like:
That is as part of your encryption process you should have a line roughly looking like:
ciphertext_letter = plaintext_letter + key_letter
and in your decryption process something roughly like:
plaintext_letter = ciphertext_letter - key_letter
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started