Problem Solving with C++, Student Value Edition
10th Edition
ISBN: 9780134543680
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8, Problem 11PP
Program Plan Intro
Decryption of the intercepted message
Program plan:
- Include necessary header files.
- Declare the namespace.
- Declare the function “decrypt()”.
- Define the function “decrypt()”.
- Declare the necessary variables.
- Use “for” loop to iterate the string length using the function “strlen()”.
- Encode the string and assign the result into the variable “Encrypt”.
- The “if” loop check the condition.
- True, use the formula to decrypt the message.
- Otherwise, use the formula to decrypt the message.
- Assign the decrypted message into the variable “decode[i]”.
- Define the “main()” function.
- Declare and initialize the necessary variables.
- Use “for” loop to iterate the number or key between “1” to “100”.
- Call the function “decrypt()”.
- Print the result.
- Return “0”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Given table is the ascii value of the characters and symbols. The following code is the code for XOR Encryption: Change the input string in the driver code at the sample string. def encrypt(inpString): xorKey = 'e'
Which of the following is the message HELLO TUTOR after xor encryption, using 'e' as the key, has been applied?
- ))*E101*7
-$55<E'H!$<
=$(E7 3,6
- ),"*)$+!6
Which of the following is the message HELIGOLANDS after xor encryption, using 'e' as the key, has been applied?
- )5E( E5)6
- ),"*)$+!6
- ))*E207)<
- ))*E2*7)!
Which of the following is the original message before xor encryption, using 'e' as the key, created - ),"*)$+!6?
HELP ME PLS
HELIGOLANDS
HELLO WURLY
HELLO WORLD
Encryption is commonly used to disguise messages on the internet. A Caesar cipher performs a shift of all of the characters in a string (based on their ASCII values, see Table 2.1), e.g. h e l l o → m j q q t The example shows a shift with a distance of 5 characters, i.e. h(ASCII:104) → m(ASCII:109) Write a C/C++ program that asks the user to input a line of plaintext and the distance value and outputs an encrypted text using a Caesar cipher, with the ASCII values range from 0 through 127. Use underscores (ASCII: 95) to represent space characters. Underscore characters should not be encrypted, and any character that is encrypted may not become an underscore. In this case, the character should be changed to the next character in the ASCII table. The program should work for any printable characters. NB: No strings (datatype) or library functions may be used. See Figure 2.1 for example output.
PYTHON3
Complete the given function, encrypt_text that encrypts the variable text using the provided key by applying a modified version of Caesar’s Cipher with the following rules:
The key will contain a word made up of the letters ‘u’ and ‘d’. The cipher will use the key to determine the direction of the shift, with a ‘u’ indicating that the character must be shifted upwards while a ‘d’ indicating a downward shift. The number of characters in the key will determine the number of positions to shift.
The given text variable will only contain characters from the ASCII table with values between 32 and 126.
If the key is invalid (empty string, contains characters other than u and d) or the text is invalid (empty string), no encryption occurs and the function returns the original text.
If the text has more characters than the key, the key will loop through again to accommodate the additional text characters.
An iterative approach should be used to solve this problem. Brute force…
Chapter 8 Solutions
Problem Solving with C++, Student Value Edition
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
Knowledge Booster
Similar questions
- Encryption is commonly used to disguise messages on the internet. A Caesar cipher performs a shift of all of the characters in a string (based on their ASCII values, see Table 2.1), e.g. h e l l o → m j q q tThe example shows a shift with a distance of 5characters, i.e. h(ASCII:104) → m(ASCII:109)Write a C/C++ program that asks the user to input a line of plaintext and the distance value and outputs an encrypted text using a Caesar cipher, with the ASCII values range from 0 through 127. Use underscores (ASCII: 95) to represent space characters.Underscore characters should not be encrypted, and any character that is encrypted may not become an underscore. In this case, the character should be changed to the next character in the ASCII table.The program should work for any printable characters.NB: No strings (datatype) or library functions may be used.See Figure 2.1 for example output.arrow_forwardA. The original Caesar cypher shifts each character by one: a becomes b, z becomes a, and so on. Let's make it a bit harder, and allow the shifted value to come from the range 1..25 inclusive. Moreover, let the code preserve the letters' case (lower-case letters will remain lower-case) and all non-alphabetical characters should remain untouched. Your task is to write a program which: asks the user for one line of text to encrypt; asks the user for a shift value (an integer number from the range 1..25 - note: you should force the user to enter a valid shift value (don't give up and don't let bad data fool you!) Test your code using the data we've provided. Test data Sample input: abcxyzABCxyz 123 2 Sample output: cdezabCDEzab 123 Sample input: The die is cast 25 Sample output: Sgd chd hr bzrsarrow_forwardPlease explain Python Code # 2) Write a procedure that takes a string and returns that string ROT13'ed.def rot13(word):encryptedword = ""for c in word:if c >= 'a' and c <= 'm': # a..mencryptedword += chr((ord(c)+13))elif c >= 'n' and c <= 'z': # n..zencryptedword += chr((ord(c)-13))else: # don't encrypt lettersencryptedword += creturn encryptedword#print(rconvertup("example"))print(rot13("example!"))print(rot13(rot13("example!")))arrow_forward
- Please help I would like when I enter a phrase in this program where the same letter in the words would like to encrypt will not be used twice E.g. To encrypt: Character Encrypted: Ingxgizkx We see that for the letter a there are two g’sarrow_forwardIn Python Create a program that reads a full name as a single string, and and uses the split creates a username with the following rules: The first character of the username is the first character of the first name. The second character of the username is the first letter of the middle name, if one was provided. The rest of the characters will be a prefix of the last name, long enough to meet the length requirement. The username can have up to 8 characters only, and in lowercase.arrow_forward// Task 2 // For this function, you must build a string that when printed,// will output the entire binary representation of the integer x,// no matter how many bits an integer is. You may NOT use// division (/) or mod (%) anywhere in your code, and should// instead rely on bitwise operations to read the underlying binary// representation of x.stringbuilder get_bin_1(int x) { stringbuilder sb = new_sb(); sb_append(sb, '$'); return sb;}arrow_forward
- 42- You are writing a program which displays an output message including the user's name and weight (to two decimal places). Which kind of string would be most appropriate to use for building the output message? Ensure that you select the answer which also includes a correct explanation. a. An f-string, because format specifiers must be included in all programs. b. An e-string, since only e-strings can be used as output. c. An e-string, because the output groups data and text elements. d. An e-string, because e-strings permit string concatenation. e. An f-string, since only f-strings can be used as output. f. An f-string, since replacement fields can be used to insert and format values.arrow_forwardyou send me an incorrect solution for those 2 questions c++ 3- Write code that checks if a number is odd or even using bitwise operators.5- Write a function that returns toggle case of a string using the bitwiseoperators in place.arrow_forwardWrite a program to decipher a numeric code in C++. After years of searching, your team has uncovered a code that could unlock ancient secrets. Based on their research, they have determined the integer 67,796,869 could be the key to the mysteries. The team is certain that the number is a sequence of 2-digit pairs, where each pair represents a letter. They need your help to write a program which displays the decoded message. After your analysis, you realize that you can use the modulus (%) to split off the last 2 digits and store it as a number. Then, you can convert (static_cast) the number to a character. Since there are 8 digits in the number, that means the message will have 4 letters (so you need 4 char variables, c1, c2, c3, c4), and you will have to "split" more than once. Once you have all 4 characters, display them (in order) to the user (The secret message is ...) The program should: contain header comments as shown in class display a "hello" message store the original number…arrow_forward
- please code in python Implement an encryption function that tests that input 0xADE1 yields ciphertext (188, 153). You may hard-code these values for testing. Do NOT use ANY string/character manipulation or arithmetic functions to implement your solution.arrow_forwardDo some research to find at least two characters in the Extended ASCII character set, and the keyboard shortcuts that allow you to enter those characters directly from the keyboard. If possible, the characters should include letters in your name from question 1, otherwise add some new characters. Type the characters, AND the shortcuts you used. For example: Jôhn Bénoït (option-i, o), (option-e, e), (option-u, i).arrow_forwardThis is C++ AND i need it ASAP please 1: You will be given two positive integers, a and b (a <= b). • If 1<=n<=9, the print the English representation of it in lowercase. That is, “one” for 1,” two” for 2 and so on. • Else if n>9 and it is an even number then print “even”. • Else if n>9 and it is an odd number, then print “odd”. • Check that a>=b and a,b>0(Positive). Write cerr and return a non-zero value if this condition does not hold. Example: 8 11 Output : eight nine even odd #include <iostream> using namespace std; int main() { int a,b; cout << "Enter the first number:"; cin >> a; cout << "Enter the second number:"; cin >> b; //you code here }arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr