I have a problem with my decoding program that I'm trying to figure out. It's supposed to read in a encrypted line of code from a .txt file and then by using ASCII values, convert that encrypted code to a decoded version. Example:
Encrypted code:
Fcjjm~rfcpc'
Decoded code: (after adding 2 to every ASCII value - or a key of 2, within ASCII # 32 - 127)
operator<< has a specific overload for char that treats the input as an ASCII character rather than a number. It was a decision that the designer/programmer of the IO streams had to make up front.
this is what I have so far, can anyone help me fix this. right now, my program compiles but it isn't outputting what it should be reading from the .txt file. thanks for the help!!
string decode(vector <char> encrypted, int key)
{
string decode;
int size = encrypted.size(), i = 0;
for (i; i < size; i++)//Scans the message from message[0] to message[99] to store character
{
for (key = 0; key < 100; key++)
{
if (int(encrypted[i]) + key > 126)
{
encrypted.push_back(char(32 + ((int(encrypted[i]) + key) - 127))); //It starts the ASCII table over when it reaches the end.
}
else
{
encrypted.push_back(char(int(encrypted[i]) + key)); //Turns the user input ASCII character to the new character, pushing all of the characters forward on the table 'key' ASCII values
}
}
}
}
this is the same problem of bradgizzie and i've replied to him, check his post.
are you both the same?? how is this possible that two people on the forum have the same problem!!!!???
i am very confused that who is writing which question and whom im replying what!!!
yeah, i think we're in the same class, but we dont know it, haha. it's working alright i s'pose. I think I have a good enough grasp on this to finish it. Thanks for all the help!