Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- #include <thread>
- #include <vector>
- std::string alp = "abcdefghijklmnopqrstuvwxyz";
- std::string message = "koh rhkbv woe tzp efscw soqzld yt jmub sigsdsyae";
- void decipher(const std::string& key, int num) {
- std::string result = message;
- for (int i = 0, j = 0; i < message.length(); ++i, j %= key.length()) {
- if (result[i] == ' ')
- continue;
- result[i] = alp[(message[i] + (alp.length() - key[j++])) % alp.length()];
- }
- if (result.find(" you ") != std::string::npos)
- std::cout << key << " " << result << " " << num << '\n';
- }
- void func(int num) {
- for (int i = (num - 1) * std::pow(26, 5) / 12; i < num * std::pow(26, 5) / 12; ++i) {
- std::string key = "";
- for (int j = 0; j < 5; ++j)
- key += alp[i / static_cast<int>(std::pow(26, 5 - j - 1)) % 26];
- decipher(key, num);
- }
- }
- int main(int argc, char* argv[]) {
- std::vector<std::thread> ths;
- for (int i = 1; i <= 12; ++i)
- ths.push_back(std::thread(func, i));
- for (int i = 0; i < 12; ++i)
- ths[i].join();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment