All the explanation is in the code comments. Hope this helps!
Code:
#include <iostream>
using namespace std;
// function to decrypt text given a caesarcipher encryption
key
string decrypt(string s, int key)
{
// decrypted text
string res = "";
// loop for all characters in s
for(int i=0; i<s.size(); i++)
{
// if s[i] is a letter
// to get decryption key, subtract key by 26
// do modulus for connecting letters in a loop
if((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A'
&& s[i] <= 'Z'))
{
if(s[i] >= 'a' && s[i] <= 'z')
res += ((s[i] - 'a') + 26 - key) % 26 + 'a';
else
res += ((s[i] - 'A') + 26 - key) % 26 + 'A';
}
// for other characters
else
{
res += s[i];
}
}
// return result
return res;
}
int main()
{
// given string
string s = "Ju yuskznotm zujge zngz euax lazaxk ykrl corr zngtq eua
lux";
// to find the decrypted text, try with every key from 1 to
25
for(int i=1; i<=25; i++)
{
cout << "For key " << i << ": " <<
decrypt(s, i) << endl;
}
// the encryption key is 6 and the decrypted message is -
// Do something today that your future self will thank you
for
return 0;
}
Sample run:
Code screenshot:
"Four".Q2: Using Caesar Cipher please do this exercise. You need to write a step-by-step description of...
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 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...
USING C LANGUAGE Write a program to compute a Caesar Cipher . You must read in a file of text and convert some of the letters to another letter using the following array: char key[27] = “efghijklmnopqrstuvwxyzabcd”; This means that if you encounter the letter ‘a’, then you will replace it with the letter ‘e’,etc. If you encounter any other characters in the input file (example: ‘A’ or space, etc, you will write them as is. You will write each...
Using Python; Caesar part of the homework: Write c_encrypt() and c_decrypt(), both of which take two arguments, the first one a string and the second one an integer key. Both should return a string. Vigenère part of the homework: Write vig_encrypt() and vig_decrypt() functions. Each takes two strings as inputs, with the first being the plaintext/ciphertext, and the second being the key. Both should be calling functions you wrote earlier to help make the work easier. The key will be...
. Please write a function that will do the following Decryption of a message encrypted with a substitution cipher given cipher text only without any key Please provide comments on each line of code outlining what that line is doing. Note: Only the Function is to be written, all user inputs i.e the text to be decrypted will be entered earlier in the program. Code must be written in C and be able to be compiled using GCC If any...
do the following in python idle 3.5 or higher know nothing on this subject Eile Edit Yew Hbtory Bookmarks bols Help Microsoft Word-Situatio x S Female coaches: Why are. x a SakaieURI:csc 110 spri.. x O lab7-crypto-s17-labr-cry. x Writer The owing Code. x https sakai. 7-Cryptog rithms -10 28 /lab7-cryp 67k e a Search A Most visited e Getting started To decode an Affine cipher, we need to reverse the process. This is not a simple as reversing a Caesar...
**DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the creatures from the classic science-fiction film "The Day of the Triffids") is an algorithm that enciphers a plaintext message by encoding each letter as a three-digit number and then breaking up and rearranging the digits from each letter's encoded form. For this assignment, you will create a set of Python functions that can encode messages using this cipher (these functions...
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...
DO NOT use cursive. Answer all the questions, please. Please write down the process in detail. Thank you. 10. (6 marks) Find the voltage vy by reducing the circuit to its simplest form, using source transformations for R1 = 212, R2 = 312, R3 = 922, R = 312, R5 = 492, Re = 612, = 2A, Vo = 20V, Vi = 5V and Vo = 20V; draw diagrams for every source transformations you make and show your work step-by-step....
Please do b,c, and d. please write step by step and write legibly. thank you. 2. Definition of Derivative a) Find the slope of the tangent line to the parabola f(x) = 4x - 32 at the point a using the definition of derivative. b) Find the equation for the tangent line to f(x) = 4.c - zº if f(1) = 3. c) Find the slope of the tangent line to f(x) = (2x2 - 4) at the point a.