xor
This xor tag encodes and decodes text using a bitwise XOR operation with a given key.
Created by: hackvertor
Installed 1 times
Category: Encrypt
Created on: Monday, October 21, 2024 at 8:47:20 PM
Updated on: Wednesday, November 6, 2024 at 3:20:41 PM
Tag arguments
[
{
"type": "string",
"help": "This provides the key to use",
"defaultValue": "key"
}
]
Code
class xor {
encode(input, key) {
return input
.split("")
.map((char, i) => {
return String.fromCharCode(
char.charCodeAt(0) ^ key.charCodeAt(i % key.length),
);
})
.join("");
}
}