aboutsummaryrefslogtreecommitdiff
path: root/src/hash/xor.c
diff options
context:
space:
mode:
authorame <[email protected]>2023-11-03 19:45:15 -0500
committerame <[email protected]>2023-11-03 19:45:15 -0500
commit5cd20516567da82c60b5513c732e23db6918a4b6 (patch)
treeec66bbcd1453fda3b7fde17ffa42b70180a149d1 /src/hash/xor.c
parentc3d9a4d44c1c6930fac277d20c6ea48801e39a18 (diff)
tons of checksums (i had fun:3)
Diffstat (limited to 'src/hash/xor.c')
-rw-r--r--src/hash/xor.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/hash/xor.c b/src/hash/xor.c
new file mode 100644
index 0000000..a2c1b0b
--- /dev/null
+++ b/src/hash/xor.c
@@ -0,0 +1,26 @@
+#include "../crypto.h"
+#include <stdio.h>
+#include <stdint.h>
+
+uint8_t i_xor8(uint8_t *aa, size_t len){
+ uint8_t a = 0;
+
+ for(int i = 0; i != len; i++)
+ a += aa[i] & 0xff;
+
+ return ((a ^ 0xff) + 1) & 0xff;
+}
+
+int l_xor8(lua_State* L){
+
+ size_t len = 0;
+ uint8_t* a = (uint8_t*)luaL_checklstring(L, 1, &len);
+
+ char digest[8];
+
+ uint8_t u = i_xor8(a, len);
+ sprintf(digest,"%x",u);
+ lua_pushstring(L, digest);
+
+ return 1;
+}