#pragma region Xor
template <int X> struct EnsureCompileTime
{
enum : int
{
Value = X
};
};
constexpr int LinearCongruentGenerator()
{
constexpr auto date = __DATE__;
constexpr auto seed_d = static_cast<int>(date[9]) * 200 + static_cast<int>(date[8]) * 700 + static_cast<int>(date[7]) * 6000 + static_cast<int>(date[6]) * 200 + static_cast<int>(date[4]) * 600 + static_cast<int>(date[3]) * 600 + static_cast<int>(date[1]) * 3600 + static_cast<int>(date[0]) * 36000;
constexpr auto time = __TIME__;
constexpr auto seed_t = static_cast<int>(time[7]) + static_cast<int>(time[6]) * 200 + static_cast<int>(time[4]) * 600 + static_cast<int>(time[3]) * 600 + static_cast<int>(time[1]) * 3600 + static_cast<int>(time[0]) * 36000;
constexpr auto seed = (seed_d + seed_t)/4;
return seed/*1013904223 + 1664525 * ((Rounds > 0) ? LinearCongruentGenerator(Rounds - 1) : seed & 0xFFFFFFFF)*/;
}
#define Random() EnsureCompileTime<LinearCongruentGenerator()>::Value
#define RandomNumber(Min, Max) (Min + (Random() % (Max - Min + 1)))
template <int... Pack> struct IndexList {};
template <typename IndexList, int Right> struct Append;
template <int... Left, int Right> struct Append<IndexList<Left...>, Right>
{
typedef IndexList<Left..., Right> Result;
};
template <int N> struct ConstructIndexList
{
typedef typename Append<typename ConstructIndexList<N - 1>::Result, N - 1>::Result Result;
};
template <> struct ConstructIndexList<0>
{
typedef IndexList<> Result;
};
#pragma warning(disable : 4307)
#pragma warning(disable : 4309)
template <typename Char_tp, typename IndexList> class crypte;
template <typename Char_tp, int... Index> class crypte<Char_tp, IndexList<Index...> >
{
private:
Char_tp Value[sizeof...(Index) + 1];
static const Char_tp XORKEY = static_cast<Char_tp>(RandomNumber(0, 0xFFFF));
template <typename Char_tp>
constexpr Char_tp EncryptCharacterT(const Char_tp Character, int Index)
{
return Character ^ (XORKEY + Index);
}
public:
__forceinline constexpr crypte(const Char_tp* const String) : Value{ EncryptCharacterT(String[Index], Index)... } {}
const Char_tp* decrypt()
{
for (int t = 0; t < sizeof...(Index); t++)
{
Value[t] = Value[t] ^ (XORKEY + t);
}
Value[sizeof...(Index)] = static_cast<Char_tp>(0);
return Value;
}
const Char_tp* get()
{
return Value;
}
};
#define xor_s( text ) ( crypte<CHAR, ConstructIndexList<(sizeof( text ) - 1)>::Result>( text ).decrypt() )
#define xor_w( text ) ( crypte<wchar_t, ConstructIndexList<(sizeof( text ) - 1) / 2>::Result>( text ).decrypt() )
#pragma endregion