/* * Encrypts data coming from std::cin and prints it to std::cout, by cyclicly * exclusive-oring the data with a key that is given as the first * command line argument. If no key is given, the data is printed * unencrypted. */#include <iostream>int main(int argc, char** argv){ char* key = 0; int c; int i = 0; if (argc > 1) key = argv[1]; // Two separate loops so unencrypted mode is faster if (key) { while ((c = std::cin.get()) != EOF) { c ^= key[i++]; std::cout.put(c); if (key[i] == 0) i = 0; } } else { while ((c = std::cin.get()) != EOF) std::cout.put(c); } return 0;}