Question

12.22 Chapter 4: Encrypt Characters Simple Caesar Cipher challenge. You'll need to correct code to print...

12.22 Chapter 4: Encrypt Characters

Simple Caesar Cipher challenge. You'll need to correct code to print ciphertext character correctly.

With offset of 3 the output should be

ORIGINAL CHARACTERS
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 
ENCRYPTED CHARACTERS
D E F G H I J K L M N O P Q R S T U V W X Y Z A B C 

Given:

/*
   Print Ciphertext Characters Correctly
*/

#include <iostream>
using namespace std;

int main(){
int i;
char c;
int offset =0;

cin>>offset;

cout << "ORIGINAL CHARACTERS" << endl;
for (i=65; i<=90; ++i){
    c = i;
    cout << c << ' ';
}
cout << endl;

cout << "ENCRYPTED CHARACTERS" << endl;  
for (i=65; i<=90; ++i){
    c = i + offset;
    cout << c << ' ';
}

return 0;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
/*
   Print Ciphertext Characters Correctly
*/

#include <iostream>

using namespace std;

int main() {
    int i;
    char c;
    int offset = 0;

    cin >> offset;

    cout << "ORIGINAL CHARACTERS" << endl;
    for (i = 65; i <= 90; ++i) {
        c = (char) i;
        cout << c << ' ';
    }
    cout << endl;

    cout << "ENCRYPTED CHARACTERS" << endl;
    for (i = 65; i <= 90; ++i) {
        c = (char) ('A' + ((i + offset - 'A') % 26));
        cout << c << ' ';
    }

    return 0;
}

3 ORIGINAL CHARACTERS A BCDEFGHIJKL MNOPQRSTUVWXYZ ENCRYPTED CHARACTERS DEFGHIJKLMNO PQR STUVWX Y 2 A B C Process finished wi

Add a comment
Know the answer?
Add Answer to:
12.22 Chapter 4: Encrypt Characters Simple Caesar Cipher challenge. You'll need to correct code to print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment 7: Caesar Cipher Assignment 7 You will create a Caesar cipher which allows the user...

    Assignment 7: Caesar Cipher Assignment 7 You will create a Caesar cipher which allows the user to specify the key and the text to be encrypted. A Caesar cipher is a simple substitution cipher wherein each letter in the message is shifted a certain number of spaces down the alphabet -- this number is called the key. a b c d e f g h i j k l m n o p q r s t u v w...

  • Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is...

    Using C++ Part C: Implement the modified Caesar cipher Objective: The goal of part C is to create a program to encode files and strings using the caesar cipher encoding method. Information about the caesar method can be found at http://www.braingle.com/brainteasers/codes/caesar.php.   Note: the standard caesar cipher uses an offset of 3. We are going to use a user supplied string to calculate an offset. See below for details on how to calculate this offset from this string. First open caesar.cpp...

  • I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text an...

    I need Help to Write a function in C that will Decrypt at least one word with a substitution cipher given cipher text and key My Current Code is: void SubDecrypt(char *message, char *encryptKey) { int iteration; int iteration_Num_Two = 0; int letter; printf("Enter Encryption Key: \n");                                                           //Display the message to enter encryption key scanf("%s", encryptKey);                                                                   //Input the Encryption key for (iteration = 0; message[iteration] != '0'; iteration++)                               //loop will continue till message reaches to end { letter = message[iteration];                                                      ...

  • Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D....

    Computer Science C++ Help, here's the question that needs to be answered (TASK D): Task D. Decryption Implement two decryption functions corresponding to the above ciphers. When decrypting ciphertext, ensure that the produced decrypted string is equal to the original plaintext: decryptCaesar(ciphertext, rshift) == plaintext decryptVigenere(ciphertext, keyword) == plaintext Write a program decryption.cpp that uses the above functions to demonstrate encryption and decryption for both ciphers. It should first ask the user to input plaintext, then ask for a right...

  • why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',...

    why is this wrong for vectors vector<char> decrypt{ {'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A'}, {'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, }; for(int...

  • Need help in c++ programming to output the lines in my code: if word if found:...

    Need help in c++ programming to output the lines in my code: if word if found:            cout << "'" << word << "' was found in the grid" << endl;            cout << "'" << word << "' was not found in the grid" << endl; The words can be touching if they are horizontally, vertically, or diagonally adjacent. For example, the board: Q W E R T A S D F G Z X C V B Y U A...

  • Write helpful comments for the following code: use Vigenere cipher tech to encrypt and decrypt message...

    Write helpful comments for the following code: use Vigenere cipher tech to encrypt and decrypt message The code: #include<stdio.h> #include <stdlib.h> char arr[26][26]; char message[22], key[22], emessage[22], retMessage[22]; int findRow(char); int findColumn(char); int findDecRow(char, int); int main() { int i = 0, j, k, r, c; k = 96; for (i = 0; i<26; i++) { k++; for (j = 0; j<26; j++) { arr[i][j] = k++; if (k == 123) k = 97; } } printf("\nEnter message\n"); fgets(message, 22,...

  • I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I...

    I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...

  • I NEED A MATHEMATICAL ALGORITHM FOR A CEASER CHYPER I CREATED. PLEASE HELP ME...THANK YOU! THE...

    I NEED A MATHEMATICAL ALGORITHM FOR A CEASER CHYPER I CREATED. PLEASE HELP ME...THANK YOU! THE SINGLE-DIGIT KEY IS 14 THE PHRASE IS "GOOD MORNING PROFESSOR" THE CYPHER IS UCCR ACFBWBU DFCTSGGCF I DON'T KNOW HOW TO CREATE THE ALGORITHM AND IT CANNOT BE COMPUTER GENERATED. a. Develop a Caesar cipher-type encryption algorithm with a little more complexity in it. For example, the algorithm could alternatively shift the cleartext letters positive and negative by the amount of the key value....

  • Develop a Java application that uses a type of encrypted alphabet, called a random monoalphabetic cipher,...

    Develop a Java application that uses a type of encrypted alphabet, called a random monoalphabetic cipher, to encrypt and decrypt a message. Your encryption key and message are to be read in from two different files and then the encrypted message will be output to third file. Then the encrypted message is read in and decrypted to a fourth file. A monoalphabetic cipher starts with an encryption word, removes the redundant letters from the word, and assigns what’s left to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT