diff options
| author | alpine <[email protected]> | 2020-06-15 21:34:40 +0200 |
|---|---|---|
| committer | alpine <[email protected]> | 2020-06-15 21:34:40 +0200 |
| commit | 19583bfb75d4a15a75d70355dd3b752bfc1d8b03 (patch) | |
| tree | 868211249e0d4011e06bef6a879f462053d3c745 /client/src/util | |
| parent | Client. (diff) | |
| download | loader-19583bfb75d4a15a75d70355dd3b752bfc1d8b03.tar.xz loader-19583bfb75d4a15a75d70355dd3b752bfc1d8b03.zip | |
Removed xor as it was slowing down everything alot.
Finished file/message streaming, really fast.
Diffstat (limited to 'client/src/util')
| -rw-r--r-- | client/src/util/xor.cpp | 41 | ||||
| -rw-r--r-- | client/src/util/xor.h | 14 |
2 files changed, 0 insertions, 55 deletions
diff --git a/client/src/util/xor.cpp b/client/src/util/xor.cpp deleted file mode 100644 index 483c161..0000000 --- a/client/src/util/xor.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "../include.h" -#include "xor.h" - -char enc::gen_key() { - std::random_device r; - - std::default_random_engine e1(r()); - std::uniform_real_distribution<> uniform_dist(0, 255); - return static_cast<char>(uniform_dist(e1)); -} - -// XOR keys at the beginning of the message for clients -void enc::encrypt_message(std::string &str) { - std::array<char, key_num> keys; - for (size_t i = 0; i < key_num; i++) { - char key = gen_key(); - keys[i] = key; - str.insert(str.begin(), key); - } - - for (auto &key : keys) { - for (size_t i = key_num; i < str.size(); i++) { - str[i] ^= key; - } - } -} - -// XOR keys at the end of the message for server messages -void enc::decrypt_message(std::string &str) { - if (str.size() <= 50) return; - - std::string keys = str.substr(str.size() - key_num); - - for (auto &key : keys) { - for (size_t i = 0; i < str.size() - key_num; i++) { - str[i] ^= key; - } - } - - str.erase(str.end() - key_num, str.end()); -}
\ No newline at end of file diff --git a/client/src/util/xor.h b/client/src/util/xor.h deleted file mode 100644 index 1ae1ce2..0000000 --- a/client/src/util/xor.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace enc { -constexpr size_t key_num = 50; - -char gen_key(); - -// XOR keys at the beginning of the message for clients -void encrypt_message(std::string &str); - -// XOR keys at the end of the message for server messages -void decrypt_message(std::string &str); - -} // namespace enc
\ No newline at end of file |