-
-
Save Cih2001/d856bdc0c67283150040e9d9406cab31 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
#include "stdio.h" | |
#define KEY 0x55 | |
template <unsigned int N> | |
struct obfuscator { | |
char m_data[N] = {0}; | |
constexpr obfuscator(const char* data) {/*...*/}; | |
/* | |
* deobfoscate decrypts the strings. Implement decryption algorithm here. | |
* Here we have a simple XOR algorithm. | |
*/ | |
void deobfoscate(unsigned char * des) const{ | |
int i = 0; | |
do { | |
des[i] = m_data[i] ^ KEY; | |
i++; | |
} while (des[i-1]); | |
} | |
}; | |
int main() { | |
// Store "Hello" in obfuscated form using simple xor encryption. | |
constexpr auto obfuscated_str = obfuscator<6>("Hello"); | |
// Create a buffed to store decrypted string. | |
unsigned char buff[0x10] = {0}; | |
// Decrypt the string | |
obfuscated_str.deobfoscate(buff); | |
printf("%s", buff); // output: Hello | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment