I am creating a program to decrypt the line of code ":mmZ\dxZmx]Zpgy" with ASCII method. What I have so far translates individual characters perfectly. But I can't seem to translate whole lines/words. Everyway I've tried gives an error somewheres. I think I need to use cstring or string. Any tips or pointers would be greatly appreciated.
#include <iostream>
using namespace std;
char Decryption(char OriginalChar, int Key); // Function declaration: Decrypts a secret code
int main()
{
char OriginalChar, Secret_Code;
int Key;
cout << "Please enter the Original Character: \n";
cin >> OriginalChar;
cout << "You entered " << (int) OriginalChar << endl;
Secret_Code = Decryption(OriginalChar, Key); // Function Call: Computes secret code
system("pause");
return 0;
}
char Decryption(char OriginalChar, int Key) // Function Definition: Outputs secret code
{
char Secret_Code;
for (Key = 0; Key <= 100; Key++)
{
if (OriginalChar - Key < 32)
{
Secret_Code = (((OriginalChar - Key) + 127) - 32); //Decrypts the code
}
else
{
Secret_Code = (OriginalChar - Key); //Decrypts the code
}
cout << endl << "Key: " << Key << endl << "This translates to: " << (char) Secret_Code << endl;
}
system("pause");
return (Secret_Code);
}