Question

In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or...

In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet.

Given an arbitrary cipher text file, you need to write a C++ program to find out the value of the shift, and decrypt the cipher text to plaintext. You must not hard code the cipher text nor any shift values in your program. Test your program with a sample cipher text here (only the alphabetic letters are changed):

Projects/caesarcipher/cipher.txt ==> "

Ty ncjaezrclasj, pyncjaetzy td esp acznpdd zq eclydqzcxtyr tyqzcxletzy (cpqpccpo ez ld awltyepie) fdtyr ly lwrzctesx (nlwwpo ntaspc) ez xlvp te fycplolmwp ez lyjzyp pinpae eszdp azddpddtyr dapntlw vyzhwporp, fdflwwj cpqpccpo ez ld l vpj. Esp cpdfwe zq esp acznpdd td pyncjaepo tyqzcxletzy (ty ncjaezrclasj, cpqpccpo ez ld ntaspcepie). "

Submit the following:

1.       Source code

2.       A screen shot showing the execution of the program and the correct offset value

3.       The plaintext file

Submit each file individually. Do not zip.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Source Code

#include <iostream>
#include <string>

using namespace std;

int main() {
   string cipherText = "Ty ncjaezrclasj, pyncjaetzy td esp acznpdd zq eclydqzcxtyr tyqzcxletzy (cpqpccpo ez ld awltyepie) fdtyr ly lwrzctesx (nlwwpo ntaspc) ez xlvp te fycplolmwp ez lyjzyp pinpae eszdp azddpddtyr dapntlw vyzhwporp, fdflwwj cpqpccpo ez ld l vpj. Esp cpdfwe zq esp acznpdd td pyncjaepo tyqzcxletzy (ty ncjaezrclasj, cpqpccpo ez ld ntaspcepie).";
    int key = 11;
    char ch;
    for(int i = 0; i < cipherText.size(); ++i) {
       ch = cipherText[i];
        if(ch >= 'A' && ch <= 'Z') {
            ch = (char) ('A' + ((ch - 'A' - key + 26) % 26));
        } else if (ch >= 'a' && ch <= 'z') {
            ch = (char) ('a' + ((ch - 'a' - key + 26) % 26));
       }
        cout << ch;
    }
    cout << endl;
   return 0;
}

2) 3) In cryptography, encryption is the process of transforming information (referred to as plaintext) using an algorithm (called cipher) to make it unreadable to anyone except those possessing special knowledge, usually referred to as a key. The result of the process is encrypted information (in cryptography, referred to as ciphertext).

Please rate it if you found this helpful, thank you :)

Add a comment
Know the answer?
Add Answer to:
In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or...
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
  • Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple...

    Caesar Cipher v3 Decription Description A Caesar cipher is one of the first and most simple encryption methods. It works by shifting all letters in the original message (plaintext) by a certain fixed amount (the amounts represents the encryption key). The resulting encoded text is called ciphertext. Example Key (Shift): 3 Plaintext: Abc Ciphertext: Def Task Your goal is to implement a Caesar cipher program that receives the key and an encrypted paragraph (with uppercase and lowercase letters, punctuations, and...

  • Using the website Repl.it Write a Java program that can perform the Caesar cipher for English...

    Using the website Repl.it Write a Java program that can perform the Caesar cipher for English messages that include both upper and lowercase alphabetic characters. The Caesar cipher replaces each plaintext letter with a different one, by a fixed number of places down the alphabet. The program should be able to shift a specific number of places based on the user's input number. For example Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG. Ciphertext: QEBNRFZH YOLTK CLU GRJMP...

  • using the website repl.it (must be done in Javascript) PGM #1 Write a Java program that can perform the Caesar cipher fo...

    using the website repl.it (must be done in Javascript) PGM #1 Write a Java program that can perform the Caesar cipher for English messages that include both upper and lowercase alphabetic characters. The Caesar cipher replaces each plaintext letter with a different one, by a fixed number of places down the alphabet. The cipher illustrated here uses a left shift of three, so that (for example) each occurrence of E in the plaintext becomes B in the ciphertext. For example...

  • Write the programming C please, not C++. The main function should be to find the offset...

    Write the programming C please, not C++. The main function should be to find the offset value of the ciper text "wPL2KLK9PWWZ7K3ST24KZYKfPMKJ4SKLYOKRP4KFKP842LK0ZTY43 " and decrypt it. In cryptography, a Caesar Cipher is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be...

  • USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is...

    USE C programming (pls label which file is libcipher.h and libcipher.c) Q4) A shift cipher is one of the simplest encryption techniques in the field of cryptography. It is a cipher in which each letter in a plain text message is replaced by a letter some fixed number of positions up the alphabet (i.e., by right shifting the alphabetic characters in the plain text message). For example, with a right shift of 2, ’A’ is replaced by ’C’, ’B’ is...

  • Cryptography, the study of secret writing, has been around for a very long time, from simplistic...

    Cryptography, the study of secret writing, has been around for a very long time, from simplistic techniques to sophisticated mathematical techniques. No matter what the form however, there are some underlying things that must be done – encrypt the message and decrypt the encoded message. One of the earliest and simplest methods ever used to encrypt and decrypt messages is called the Caesar cipher method, used by Julius Caesar during the Gallic war. According to this method, letters of the...

  • 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...

  • Python program Use the provided shift function to create a caesar cipher program. Your program s...

    python program Use the provided shift function to create a caesar cipher program. Your program should have a menu to offer the following options: Read a file as current message Save current message Type in a new message Display current message "Encrypt" message Change the shift value For more details, see the comments in the provided code. NO GLOBAL VARIABLES! Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR...

  • Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util...

    Change the following Shift Cipher program so that it uses OOP(constructor, ect.) import java.util.*; import java.lang.*; /** * * @author STEP */ public class ShiftCipher { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner(System.in); String plainText; System.out.print("Please enter your string: "); // get message plainText = input.nextLine(); System.out.print("Please enter your shift cipher key: "); // get s int s = input.nextInt(); int...

  • Computer Security Question about the Caesar Cipher: I also don't know this part of the problem...

    Computer Security Question about the Caesar Cipher: I also don't know this part of the problem Hello I am not sure how to figure this out Hello so for question 3, I think its +23 "the password is qqzzqqz" choose the correct multiple choice Question1 2 pts The following cipher text was produced by the Caesar Cipher: The Caesar cipher cryptanalysis technique from lecture calculates the most likely keys. When the technique is applied in this case, which of the...

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