-
-
Save Cih2001/f6adcfb29e3a9a0b0aafe7b1c263fbdc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define KEY 0x55 | |
template <unsigned int N> | |
struct obfuscator { | |
/* | |
* m_data stores the obfuscated string. | |
*/ | |
char m_data[N] = {0}; | |
/* | |
* Using constexpr ensures that the strings will be obfuscated in this | |
* constructor function at compile time. | |
*/ | |
constexpr obfuscator(const char* data) { | |
/* | |
* Implement encryption algorithm here. | |
* Here we have simple XOR algorithm. | |
*/ | |
for (unsigned int i = 0; i < N; i++) { | |
m_data[i] = data[i] ^ KEY; | |
} | |
} | |
}; | |
int main() { | |
// Store "Hello" in obfuscated form using simple xor encryption. | |
constexpr auto obfuscated_str = obfuscator<6>("Hello"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment