obs-studio/UI/obf.c
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00

27 lines
492 B
C

#include "obf.h"
#include <stdbool.h>
#define LOWER_HALFBYTE(x) ((x)&0xF)
#define UPPER_HALFBYTE(x) (((x) >> 4) & 0xF)
void deobfuscate_str(char *str, uint64_t val)
{
uint8_t *dec_val = (uint8_t *)&val;
int i = 0;
while (*str != 0) {
int pos = i / 2;
bool bottom = (i % 2) == 0;
uint8_t *ch = (uint8_t *)str;
uint8_t xor = bottom ? LOWER_HALFBYTE(dec_val[pos])
: UPPER_HALFBYTE(dec_val[pos]);
*ch ^= xor;
if (++i == sizeof(uint64_t) * 2)
i = 0;
str++;
}
}