diff options
| author | daniel <daniel@planethacker.net> | 2025-05-07 09:45:50 -0700 |
|---|---|---|
| committer | daniel <daniel@planethacker.net> | 2025-05-07 09:45:50 -0700 |
| commit | eeac69b2168c5a65f9608771006ccc43033cbd23 (patch) | |
| tree | 1dc44a6016b607085a691768810d551045df9901 /crypt.c | |
Diffstat (limited to 'crypt.c')
| -rw-r--r-- | crypt.c | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -0,0 +1,50 @@ +/* + * LOKI3 + * + * [ crypt.c ] + * + * 1996/7 Guild Corporation Worldwide [daemon9] + */ + +#include "loki.h" +#include "crypt.h" + +#ifdef WEAK_CRYPTO +/* + * Simple XOR obfuscation. + * + * ( Syko was right -- the following didn't work under certain compilation + * environments... Never write code in which the order of evaluation defines + * the result. See K&R page 53, at the bottom... ) + * + * if (!m) while (i < bs) t[i] ^= t[i++ +1]; + * else + * { + * i = bs; + * while (i) t[i - 1] ^= t[i--]; + * } + * + */ +void blur(int m, int bs, uint8_t *t) { + int i = 0; + + if (!m) { /* Encrypt */ + while (i < bs) { + t[i] ^= t[i + 1]; + i++; + } + } else { /* Decrypt */ + i = bs; + while (i) { + t[i - 1] ^= t[i]; + i--; + } + } +} +#endif /* WEAK_CRYPTO */ + +#ifdef NO_CRYPTO +void blur(int m, int bs, uint8_t *t){} +#endif /* NO_CRYPTO */ + +/* EOF */ |
