From af63e27f00b679605dca416882da33d9bb0c8b36 Mon Sep 17 00:00:00 2001 From: revsic Date: Sun, 17 Feb 2019 23:13:10 +0900 Subject: [PATCH] obfs: Merged --- obfuscator.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 obfuscator.hpp diff --git a/obfuscator.hpp b/obfuscator.hpp new file mode 100644 index 0000000..dd63612 --- /dev/null +++ b/obfuscator.hpp @@ -0,0 +1,42 @@ +#ifndef OBFUSCATOR_HPP +#define OBFUSCATOR_HPP + +#include + +#define STRING_OBFS + + +namespace obfs { + template + class String { + public: + template + constexpr String(char const* str, + std::index_sequence): + str{ encoder(str[Idx])... } { + // Do Nothing + } + + constexpr size_t len() const { + return size; + } + + inline char const* decode() const { + for (char& chr : str) { + chr = decoder(chr); + } + return str; + } + + private: + mutable char str[size]; + }; + + template + constexpr auto make_string(char const (&str)[size]) { + return String(str, std::make_index_sequence()); + } +} + + +#endif