7.7 Caesar Cipher Today you will be decoding secret messages. We will be using Caesar Cipher, that was used by Caesar (t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

7.7 Caesar Cipher Today you will be decoding secret messages. We will be using Caesar Cipher, that was used by Caesar (t

Post by answerhappygod »

7 7 Caesar Cipher Today You Will Be Decoding Secret Messages We Will Be Using Caesar Cipher That Was Used By Caesar T 1
7 7 Caesar Cipher Today You Will Be Decoding Secret Messages We Will Be Using Caesar Cipher That Was Used By Caesar T 1 (61.68 KiB) Viewed 69 times
7 7 Caesar Cipher Today You Will Be Decoding Secret Messages We Will Be Using Caesar Cipher That Was Used By Caesar T 2
7 7 Caesar Cipher Today You Will Be Decoding Secret Messages We Will Be Using Caesar Cipher That Was Used By Caesar T 2 (55.58 KiB) Viewed 69 times
c++ code
starter code:
/* Cipher Lab using C strings */
/* Running the program looks like:Enter some lower-case text: helloShifting 0 gives: helloShifting 1 gives: ifmmpShifting 2 gives: jgnnqShifting 3 gives: khoorShifting 4 gives: lippsShifting 5 gives: mjqqtShifting 6 gives: nkrruShifting 7 gives: olssvShifting 8 gives: pmttwShifting 9 gives: qnuuxShifting 10 gives: rovvyShifting 11 gives: spwwzShifting 12 gives: tqxxaShifting 13 gives: uryybShifting 14 gives: vszzcShifting 15 gives: wtaadShifting 16 gives: xubbeShifting 17 gives: yvccfShifting 18 gives: zwddgShifting 19 gives: axeehShifting 20 gives: byffiShifting 21 gives: czggjShifting 22 gives: dahhkShifting 23 gives: ebiilShifting 24 gives: fcjjmShifting 25 gives: gdkkn*/
#include <iostream>#include <iomanip>#include <cctype>
using namespace std;
// Global constantsconst int MaxWordSize = 81; // 80 characters + 1 for NULL
// Given an array of characters and a shift value:// shift each character in the original text by some amount,// storing the result into the shiftedText array.// Remember: Wrap around at the end of the alphabet.// *** In the line below you must supply the function// return type and the parameter(s) ***? shiftTheText( ? ){// Loop through each character in the C string, startingText// When the character is an alphabetic character,// shift it by adding the shift value.// Then store the resulting character in its proper spot// in the shiftedText C string.
}
int main(){// Initialize the variableschar startingText[ MaxWordSize];char shiftedText[ MaxWordSize];
cout << "Enter some lower-case text: ";cin >> startingText;
for( int shiftValue = 0; shiftValue < 26; shiftValue++){// In the function call below you need to pass the starting textarray, the shift value, and the shifted text array.shiftTheText( );cout << "Shifting " << setw( 2) << shiftValue<< " gives: " << shiftedText << endl;}return 0; // Keep C++ happy
}// end main()
7.7 Caesar Cipher Today you will be decoding secret messages. We will be using Caesar Cipher, that was used by Caesar (the roman politician and military general) to pass messages to his army. It is a shift cipher which works by shifting the positions of the text. For example if you had to encrypt the word ocean by shifting the alphabets by 5: we would shift 'o' by 5 to get 't', 'c' by 5 to get 'h' and so on. So the word, PlainText: **ocean** Shifted Text: **thjfs**, Cipher shift by 5. Where we can assume if plaintext to cipher map as below for shift by 5: Plain: Cipher: ABCDEFGHIJKLMNOPQRSTUVWXYZ FGHIJKLMNOPQRSTUVWXYZABCDE Shifting by 5 means alphabet A becomes alphabet F i.e. A the first alphabet becomes the (1+5=6) alphabet F, and so on. HINT: The alphabets wrap so that A comes after Z. Shifting thjfs by 21 gives you Shifted Text: ocean Running the program looks like: Enter some lower-case text: hello Shifting 0 gives: hello Shifting 1 gives: ifmmp Shifting 2 gives: jgnng Shifting 3 gives: khoor Shifting 4 gives: lipps Shifting 5 gives: mjqgt Shifting 6 gives: nkrru Shifting 7 gives: olssv Shifting 8 gives: pmttw Shifting 9 gives: qnuux Shifting 10 gives: rovvy Shifting 11 gives: spwwz Shifting 12 gives: tqxxa Shifting 13 gives: uryyb Shifting 14 gives: vszzc Shifting 15 gives: wtaad Shifting 16 gives: xubbe Shifting 17 gives: yvccf Shifting 18 gives: zwddg Shifting 19 gives: axeeh Shifting 20 gives: byffi Shifting 21 gives: czggj Shifting 22 gives: dahhk Shifting 23 gives: ebiil Shifting 24 gives: fcjjm Shifting 25 gives: gdkkn
But, we have given you text that is shifted like thjfs from the above example. You have to shift the letters to read what it says. We have given you the main. You will write your code in the functions. Step 1: Write the function ?? shiftThetext(???), supply the parameters and the return type. Step 2:) The function shiftTheText() will shift each alphabet given by the shift integer. • Given an array of characters and a shift value, shift each character in the original text by some amount, storing the result into the shifted Text array. Wrap around at the end of the alphabet (like in the plaintext to cipher mapping A appears after Z). Running the test for Stage 2: • only one of the output will make sense. (See example below: Shifting 17 gives: hello) Enter some lower-case text: qnuux Shifting 0 gives: qnuux Shifting 1 gives: rovvy Shifting 2 gives: spwwz Shifting 3 gives: tqxxa Shifting 4 gives: uryyb Shifting 5 gives: vsZzc Shifting 6 gives: wtaad Shifting 7 gives: xubbe Shifting 8 gives: yvccf Shifting 9 gives: zwddg Shifting 10 gives: axeeh Shifting 11 gives: byffi Shifting 12 gives: czggj Shifting 13 gives: dahhk Shifting 14 gives: ebiil Shifting 15 gives: fcjjm Shifting 16 gives: gdkkn Shifting 17 gives: hello Shifting 18 gives: ifmmp Shifting 19 gives: jgnng Shifting 20 gives: khoor Shifting 21 gives: lipps Shifting 22 gives: mjqqt Shifting 23 gives: nkrru Shifting 24 gives: olssv Shifting 25 gives: pmttw
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply