Skip to content

Instantly share code, notes, and snippets.

@Cyang39
Created September 26, 2023 06:57
Show Gist options
  • Save Cyang39/a3d028f423bde6a18367301526b7fe51 to your computer and use it in GitHub Desktop.
Save Cyang39/a3d028f423bde6a18367301526b7fe51 to your computer and use it in GitHub Desktop.
xorcal
function calculateXOR(str) {
let xorValue = 0;
for (let i = 0; i < str.length; i += 2) {
const hex = str.substr(i, 2);
const decimal = parseInt(hex, 16);
xorValue ^= decimal;
}
const xorHex = xorValue.toString(16).toUpperCase().padStart(2, '0');
return xorHex;
}
console.log(calculateXOR("001C010177210288902309261444521212485703103641000000003B"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment