Hello everyone
I need help with this question? can anybody tell me how to start?
I wrote the first thing but then I couldn't proceed..
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
string wordToEncode;
cout << "Please enter the word that you want to encode" << endl;
cin >> wordToEncode
}
|
In cryptography, Caesar cipher is one of the simplest encryption techniques. The key idea of this method is to replace each plaintext letter with one fixed number of places down the alphabet. Below is an example with a shift of three:
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
Cipher: DEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABC
To cipher a string, ‘A’ is replaced by ‘D’, ‘B’ is substituted by ‘E’, and so on. To decode a string, ‘A’ is replaced by ‘x’, etc.
By using the Caesar cipher with a shift of three, write a program that first ask user to input a word (such as Student). Then, your code will print out the encoded word for the input (i.e., Vwxghqw for Student. Next, your code asks users to input a ciphered code (such as Vwxghqw), and a decoded word will be finally printed out.
Test your program with a word: “Student”. Demonstrate the encoded word and the deciphering of the encoded word.
Hint: the length of a char array can be determined by a built-in function: strlen(char_array_name), which returns an integer that is the length of the char array.