From 6342ea76413054337f226e115ee1e31e650c9cb8 Mon Sep 17 00:00:00 2001 From: alpine Date: Sat, 27 Jun 2020 02:17:50 +0200 Subject: Finished pe image implementation wrapper. Moved some files to more appropriate folders. Added linuxpe submodule. Added linuxpe as a precompiled header. --- client/src/client/enc.cpp | 34 ++++++++++++++++++++++++++++++++++ client/src/client/enc.h | 8 ++++++++ client/src/client/packet.h | 2 +- client/src/util/enc.cpp | 34 ---------------------------------- client/src/util/enc.h | 8 -------- 5 files changed, 43 insertions(+), 43 deletions(-) create mode 100644 client/src/client/enc.cpp create mode 100644 client/src/client/enc.h delete mode 100644 client/src/util/enc.cpp delete mode 100644 client/src/util/enc.h (limited to 'client/src') diff --git a/client/src/client/enc.cpp b/client/src/client/enc.cpp new file mode 100644 index 0000000..6a7baed --- /dev/null +++ b/client/src/client/enc.cpp @@ -0,0 +1,34 @@ +#include "../include.h" +#include "enc.h" + +namespace enc { + +void encrypt_message(std::string &str) { + std::random_device r; + std::default_random_engine e1(r()); + std::uniform_int_distribution gen(0, 255); + + char k1 = static_cast(gen(e1)); + char k2 = static_cast(gen(e1)); + for (int i = 0; i < str.size(); i++) { + char k = (i % 2) ? k1 : k2; + str[i] ^= k; + } + str.insert(str.begin(), k1); + str.insert(str.end(), k2); +} + +void decrypt_message(std::string &str) { + char k1 = str[0]; + char k2 = str[str.size() - 1]; + + str.erase(str.begin()); + str.erase(str.end() - 1); + + for (int i = 0; i < str.size(); i++) { + char k = (i % 2) ? k1 : k2; + str[i] ^= k; + } +} + +}; // namespace enc \ No newline at end of file diff --git a/client/src/client/enc.h b/client/src/client/enc.h new file mode 100644 index 0000000..ae8d5a6 --- /dev/null +++ b/client/src/client/enc.h @@ -0,0 +1,8 @@ +#pragma once + +namespace enc { + +void encrypt_message(std::string &str); +void decrypt_message(std::string &str); + +}; // namespace enc \ No newline at end of file diff --git a/client/src/client/packet.h b/client/src/client/packet.h index d6594b9..d1b7001 100644 --- a/client/src/client/packet.h +++ b/client/src/client/packet.h @@ -1,5 +1,5 @@ #pragma once -#include "../util/enc.h" +#include "enc.h" namespace tcp { constexpr size_t session_id_len = 10; diff --git a/client/src/util/enc.cpp b/client/src/util/enc.cpp deleted file mode 100644 index 6a7baed..0000000 --- a/client/src/util/enc.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "../include.h" -#include "enc.h" - -namespace enc { - -void encrypt_message(std::string &str) { - std::random_device r; - std::default_random_engine e1(r()); - std::uniform_int_distribution gen(0, 255); - - char k1 = static_cast(gen(e1)); - char k2 = static_cast(gen(e1)); - for (int i = 0; i < str.size(); i++) { - char k = (i % 2) ? k1 : k2; - str[i] ^= k; - } - str.insert(str.begin(), k1); - str.insert(str.end(), k2); -} - -void decrypt_message(std::string &str) { - char k1 = str[0]; - char k2 = str[str.size() - 1]; - - str.erase(str.begin()); - str.erase(str.end() - 1); - - for (int i = 0; i < str.size(); i++) { - char k = (i % 2) ? k1 : k2; - str[i] ^= k; - } -} - -}; // namespace enc \ No newline at end of file diff --git a/client/src/util/enc.h b/client/src/util/enc.h deleted file mode 100644 index ae8d5a6..0000000 --- a/client/src/util/enc.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace enc { - -void encrypt_message(std::string &str); -void decrypt_message(std::string &str); - -}; // namespace enc \ No newline at end of file -- cgit v1.2.3