diff --git a/Source/Contents/Configuration/ServiceConfiguration.cpp b/Source/Contents/Configuration/ServiceConfiguration.cpp index b36e68aa6..a57c11468 100644 --- a/Source/Contents/Configuration/ServiceConfiguration.cpp +++ b/Source/Contents/Configuration/ServiceConfiguration.cpp @@ -21,6 +21,7 @@ #include "Utility/Text/FormatString.h" #include "UI/Login/UILoginWnd.h" #include "Utility/Cipher/LocalEncryptedName.h" +#include "Utility/Cipher/CryptName.h" #include #include diff --git a/Source/Utility/Cipher/CryptName.h b/Source/Utility/Cipher/CryptName.h new file mode 100644 index 000000000..85a9b5139 --- /dev/null +++ b/Source/Utility/Cipher/CryptName.h @@ -0,0 +1,39 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_CIPHER_CRYPTNAME_H +#define RAGNAROK_SOURCE_UTILITY_CIPHER_CRYPTNAME_H + +#include +#include +#include + +namespace utility { + + template + struct CryptedText { + char data[Length]; + + // INLINED + template + constexpr operator std::array() const { + std::array out{}; + for (std::size_t index = 0; index < Length; ++index) { + out[index] = static_cast(this->data[index]); + } + return out; + } + }; + + // INLINED + template + constexpr CryptedText CryptText(const char (&text)[Length]) { + CryptedText out{}; + for (std::size_t index = 0; index < Length; ++index) { + out.data[index] = static_cast(static_cast(text[index]) ^ static_cast(Key >> (8 * (index & 7)))); + } + return out; + } + +} + +#define CRYPT_NAME(text, key) (::utility::CryptText(text)) + +#endif