1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <Windows.h>
using namespace std;
int main()
{
string code;
string message;
while (true)
{
SetConsoleTitleA((LPCSTR)"Encryption/Decryption Software");
cout << "Encrypt or Decrypt: ";
cin >> code;
if (code == "encrypt")
{
cout << "Input the message would u like to Encrypt" << endl;
SetConsoleTitleA((LPCSTR)"Encoding . . .");
getline(cin >> ws, message);
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c += 13) && c > 'z') c -= 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c += 10) && c > 'z') c -= 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c += 1) && c > 'z') c -= 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c += 20) && c > 'z') c -= 26; return c; });
cout << message << endl;
continue;
}
else if (code == "decrypt")
{
cout << "Input the message would u like to Decrypt" << endl;
SetConsoleTitleA((LPCSTR)"Decoding . . .");
getline(cin >> ws, message);
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c -= 13) && c < 'a') c += 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c -= 10) && c < 'a') c += 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c -= 1) && c < 'a') c += 26; return c; });
transform(message.begin(), message.end(), message.begin(), [](int c){ if (isalpha(c) && (c = tolower(c)) && (c -= 20) && c < 'a') c += 26; return c; });
cout << message << endl;
continue;
}
else
{
cout << "Sorry, that is none of the choices please try again" << endl;
continue;
}
return 0;
}
}
|