Sunday, September 29, 2013

Help with simple encryption

Hello everyone,

I am having trouble with an assignment. The assignment consists of a basic encryption and decryption program already written for me, I just have to write the encryption function. What we have to get the program to do is enter an integer and a text, and get the program to increment each letter in the text by the integer given. I did this by using a for loop and incrementing each value in the string by the integer.

However, I still can't get it to decrypt and I need the program to work with only a-z letters (if I increment each letter by 3 and I have the letter Z, it should go to Z+3 = C).

I attached the description of the attachment and below are the codes: The first file does not need to be edited.

Thanks for helping :)

Link to image of assignment:

/*******************Programming Assignment 1***************/ /****************Caesar's substitution cipher**************/ /*****************YOU MUST NOT EDIT THIS FILE**************/ /****Substitute alphabets in a string using rotation key***/ /****Leave all other characters unchanged******************/ /****Confirm correct encryption by decrypting**************/ /****to recover original text******************************/ #include "encrypt.h" #include "studentID.h" using namespace std; int main () { // define the rotation index variable and //the new rotation index variable to recover the text int rot, newrot; // define the input string (input), encrypted string (output) // and the recovered string (decrypted) string input, output, decrypted; // top level loop to perform encryptions while (1) { std::cout rot; // if the user is done (rot == -1), then exit if (rot == -1) break; // read in the text to be encrypted (terminated by new line) // use "ignore" method of stream cin to get rid of // accumulated new line characters std::cout
Full Post

No comments:

Post a Comment