mirror of
https://github.com/KyleBanks/XOREncryption.git
synced 2023-08-10 21:13:15 +03:00
Initial commit
This commit is contained in:
parent
a585e6d890
commit
baf3543f2e
33
main.cpp
Normal file
33
main.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// main.cpp
|
||||
// test
|
||||
//
|
||||
// Created by Kyle Banks on 2013-10-05.
|
||||
// Copyright (c) 2013 Kyle Banks. All rights reserved.
|
||||
//
|
||||
|
||||
#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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user