C++ program Write a program that will include a method for encrypting a string and a method to decrypt a string. An "encrypted" string is a string that has been altered based on a formula so it is no longer understandable. This string can also be "decrypted" to return the value of the original string. This program needs to have 3 methods - main(), a method to encrypt a passed string and return the generated results, a method to decrypt a generated string an return the results. The encrypt and decrypt methods must be value methods that return results. No display related code is expected in these methods. Do not use c-strings/char arrays in the assignment. Use the String class as described in section 10.7. ************************* To encrypt a string, Add 1 to each character of the string. Thus 'A' becomes 'B', "X" becomes "Y", etc. To decrypt a string, reduce it's value by 1. string myWord = "Hello World!"; string encryptedWord = myWord; // sets the same size For each char - loop encryptedWord[idx] = myWord[idx] +1; ******************************** The program must do the following: Prompt for a name Call the encrypt method and pass it the inputted name. Store and then display the returned results. Call the decrypt method and pass it the result from Step X. Store and then display the returned results results. The result of the decryption should match the original input. The program will loop and prompt me to continue.
C++ program
Write a program that will include a method for encrypting a string and a method to decrypt a string. An "encrypted" string is a string that has been altered based on a formula so it is no longer understandable. This string can also be "decrypted" to return the value of the original string.
This program needs to have 3 methods - main(), a method to encrypt a passed string and return the generated results, a method to decrypt a generated string an return the results.
The encrypt and decrypt methods must be value methods that return results. No display related code is expected in these methods.
Do not use c-strings/char arrays in the assignment. Use the String class as described in section 10.7.
*************************
To encrypt a string, Add 1 to each character of the string. Thus 'A' becomes 'B', "X" becomes "Y", etc. To decrypt a string, reduce it's value by 1.
string myWord = "Hello World!";
string encryptedWord = myWord; // sets the same size
For each char - loop
encryptedWord[idx] = myWord[idx] +1;
********************************
The program must do the following:
- Prompt for a name
- Call the encrypt method and pass it the inputted name. Store and then display the returned results.
- Call the decrypt method and pass it the result from Step X. Store and then display the returned results results.
- The result of the decryption should match the original input.
- The program will loop and prompt me to continue.

C++ code for encryption and decryption
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images









