Since things didn't work out between me and mbedtls, here are the basic encryption algorithms.
Embed:
(wiki syntax)
Show/hide line numbers
xor.cpp
00001 #include <iostream> 00002 00003 using namespace std; 00004 00005 string encryptDecrypt(string toEncrypt) { 00006 char key[3] = {'K', 'C', 'Q'}; 00007 string output = toEncrypt; 00008 00009 for (int i = 0; i < toEncrypt.size(); i++) 00010 output[i] = toEncrypt[i] ^ key[i % (sizeof(key) / sizeof(char))]; 00011 00012 return output; 00013 } 00014 int main(int argc, const char * argv[]) 00015 { 00016 string encrypted = encryptDecrypt("Priyanshu"); 00017 cout << "Encrypted:" << encrypted << "\n"; 00018 00019 string decrypted = encryptDecrypt(encrypted); 00020 cout << "Decrypted:" << decrypted << "\n"; 00021 00022 return 0; 00023 }
Generated on Thu Jul 21 2022 11:53:31 by 1.7.2