Skip to content

Instantly share code, notes, and snippets.

@vKxni
Created December 24, 2022 10:52
Show Gist options
  • Save vKxni/ffad7516bcdfc3c6284636c80e741705 to your computer and use it in GitHub Desktop.
Save vKxni/ffad7516bcdfc3c6284636c80e741705 to your computer and use it in GitHub Desktop.
Caesar cipher implementation in C++20
#include <iostream>
#include <fstream>
#include <string>
// The number of places to shift the letters in the Caesar cipher
const int SHIFT = 3;
int main() {
std::ofstream out_file("user_ids.txt");
for (int i = 0; i < 1000000000; ++i) {
std::string user_id = std::to_string(i) + std::to_string(rand());
std::string encrypted_user_id;
for (char c : user_id) {
encrypted_user_id += (c + SHIFT) % 26;
}
out_file << encrypted_user_id << std::endl;
}
std ::cout << "Done!" << std::endl;
std::cout << "Took: " << (clock() / (double) CLOCKS_PER_SEC) << " seconds" << std::endl;
out_file.close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment