Created
December 24, 2022 10:52
-
-
Save vKxni/ffad7516bcdfc3c6284636c80e741705 to your computer and use it in GitHub Desktop.
Caesar cipher implementation in C++20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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