From eeac69b2168c5a65f9608771006ccc43033cbd23 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 7 May 2025 09:45:50 -0700 Subject: initial commit --- crypt.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 crypt.c (limited to 'crypt.c') diff --git a/crypt.c b/crypt.c new file mode 100644 index 0000000..b39ab61 --- /dev/null +++ b/crypt.c @@ -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 */ -- cgit v1.2.3