Created
September 26, 2023 06:57
-
-
Save Cyang39/a3d028f423bde6a18367301526b7fe51 to your computer and use it in GitHub Desktop.
xorcal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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