-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (22 loc) · 685 Bytes
/
main.cpp
File metadata and controls
31 lines (22 loc) · 685 Bytes
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
//
// main.cpp
//
// Created by Kyle Banks on 2013-10-05.
//
#include <iostream>
using namespace std;
string encryptDecrypt(string toEncrypt) {
char key[3] = {'K', 'C', 'Q'}; //Any chars will work, in an array of any size
string output = toEncrypt;
for (int i = 0; i < toEncrypt.size(); i++)
output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))];
return output;
}
int main(int argc, const char * argv[])
{
string encrypted = encryptDecrypt("kylewbanks.com");
cout << "Encrypted:" << encrypted << "\n";
string decrypted = encryptDecrypt(encrypted);
cout << "Decrypted:" << decrypted << "\n";
return 0;
}