Created
August 26, 2025 05:17
-
-
Save NamesMT/82e3ceccdde3c8e3aeb8613a353fd6d3 to your computer and use it in GitHub Desktop.
RFID tag UID to dual 125khz / 13.56mhz duplicator decimal format
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 uidHexToDecimal(uidHex) { | |
| // Ensure the input is 8 hex chars (4 bytes) | |
| if (uidHex.length !== 8 || /[^0-9A-Fa-f]/.test(uidHex)) { | |
| throw new Error("UID must be a 4-byte hex string (8 hex digits)."); | |
| } | |
| // Parse the bytes from the hex string | |
| const b0 = parseInt(uidHex.slice(0, 2), 16); // first byte | |
| const b1 = parseInt(uidHex.slice(2, 4), 16); // second byte | |
| const b2 = parseInt(uidHex.slice(4, 6), 16); // third byte | |
| const b3 = parseInt(uidHex.slice(6, 8), 16); // fourth byte (may be ignored) | |
| // Convert to decimal: little-endian order, using bytes 0-2 and dropping byte3 | |
| const decimalValue = (b2 << 16) | (b1 << 8) | b0; | |
| return decimalValue; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment