rewrite to a module

This commit is contained in:
Mystikfluu
2022-08-19 19:29:14 +02:00
parent c78f4cba3a
commit 6ed17497c5
13 changed files with 1522 additions and 540 deletions
+9 -17
View File
@@ -1,27 +1,19 @@
function XOR_hex(a, b) {
var res = "",
i = a.length,
j = b.length;
while (i-->0 && j-->0)
var res = "", i = a.length, j = b.length;
while (i-- > 0 && j-- > 0)
res = (parseInt(a.charAt(i), 16) ^ parseInt(b.charAt(j), 16)).toString(16) + res;
return res;
}
function hexEncode(a){
function hexEncode(a) {
let hex;
let result = "";
for (let i=0; i<a.length; i++) {
for (let i = 0; i < a.length; i++) {
hex = a.charCodeAt(i).toString(16);
result += ("000"+hex).slice(-4);
result += ("000" + hex).slice(-4);
}
return result
return result;
}
function xor(a,b) {
return XOR_hex(hexEncode(a),hexEncode(b)).toString("hex")
function xor(a, b) {
return XOR_hex(hexEncode(a), hexEncode(b)).toString("hex");
}
module.exports = xor
export default xor;