diff --git a/obfuscator.hpp b/obfuscator.hpp index b7dbbdc..83d2500 100644 --- a/obfuscator.hpp +++ b/obfuscator.hpp @@ -176,22 +176,22 @@ namespace obfs { namespace obfs { + using size_t = decltype(sizeof(void*)); + constexpr char TIME[] = __TIME__; constexpr int digit(char c) { return c - '0'; } - constexpr int SEED = digit(TIME[7]) + + constexpr size_t SEED = digit(TIME[7]) + digit(TIME[6]) * 10 + digit(TIME[4]) * 60 + digit(TIME[3]) * 600 + digit(TIME[1]) * 3600 + digit(TIME[0]) * 36000; - using size_t = decltype(sizeof(void*)); - - template + template struct Xorshiftplus { - using prev = Xorshiftplus; + using prev = Xorshiftplus; constexpr static size_t update() { constexpr size_t x = prev::state0 ^ (prev::state0 << 23); @@ -205,15 +205,15 @@ namespace obfs { constexpr static size_t value = state0 + state1; }; - template <> - struct Xorshiftplus<0> { - constexpr static size_t state0 = static_cast(SEED); - constexpr static size_t state1 = static_cast(SEED << 1); + template + struct Xorshiftplus { + constexpr static size_t state0 = Seed; + constexpr static size_t state1 = Seed << 1; constexpr static size_t value = state0 + state1; }; template - constexpr size_t RAND_VAL = Xorshiftplus::value % Mod; + constexpr size_t RAND_VAL = Xorshiftplus::value % Mod; } diff --git a/obfuscator/obfs/random.hpp b/obfuscator/obfs/random.hpp index ba760de..f5b9ace 100644 --- a/obfuscator/obfs/random.hpp +++ b/obfuscator/obfs/random.hpp @@ -2,22 +2,22 @@ #define COMPILE_TIME_RANDOM namespace obfs { + using size_t = decltype(sizeof(void*)); + constexpr char TIME[] = __TIME__; constexpr int digit(char c) { return c - '0'; } - constexpr int SEED = digit(TIME[7]) + + constexpr size_t SEED = digit(TIME[7]) + digit(TIME[6]) * 10 + digit(TIME[4]) * 60 + digit(TIME[3]) * 600 + digit(TIME[1]) * 3600 + digit(TIME[0]) * 36000; - using size_t = decltype(sizeof(void*)); - - template + template struct Xorshiftplus { - using prev = Xorshiftplus; + using prev = Xorshiftplus; constexpr static size_t update() { constexpr size_t x = prev::state0 ^ (prev::state0 << 23); @@ -31,15 +31,15 @@ namespace obfs { constexpr static size_t value = state0 + state1; }; - template <> - struct Xorshiftplus<0> { - constexpr static size_t state0 = static_cast(SEED); - constexpr static size_t state1 = static_cast(SEED << 1); + template + struct Xorshiftplus { + constexpr static size_t state0 = Seed; + constexpr static size_t state1 = Seed << 1; constexpr static size_t value = state0 + state1; }; template - constexpr size_t RAND_VAL = Xorshiftplus::value % Mod; + constexpr size_t RAND_VAL = Xorshiftplus::value % Mod; } #define MAKE_RAND_VAL(MOD) RAND_VAL<__LINE__, MOD>