function xorBytes(a: Uint8Array, b: Uint8Array): Uint8Array {
const result: Uint8Array<ArrayBuffer> = new Uint8Array(a.length);
for (let i: number = 0; i < a.length; i++) {
result[i] = a[i] ^ b[i];
}
return result;
}
function printBitsetArray(label: string, array: Uint8Array): void {
let output: string = label + ": ";
for (const byte of array) {
output += byte.toString(2).padStart(8, '0') + " ";
}
console.log(output);
}
// Initialize arrays using ASCII codes
const a: Uint8Array = new Uint8Array([..."Aeryn"].map(ch => ch.charCodeAt(0)));
const b: Uint8Array = new Uint8Array([..."Albus"].map(ch => ch.charCodeAt(0)));
const c: Uint8Array = xorBytes(a, b);
printBitsetArray("a", a);
printBitsetArray("b", b);
printBitsetArray("c", c);
let s: string = "";
for (const byte of c) {
s += byte + " ";
}
console.log("c: " + s);
/*
run:
"a: 01000001 01100101 01110010 01111001 01101110 "
"b: 01000001 01101100 01100010 01110101 01110011 "
"c: 00000000 00001001 00010000 00001100 00011101 "
"c: 0 9 16 12 29 "
*/