-
-
Save tkerby/1187f2e6601c63b4c681d77dd18bc9f4 to your computer and use it in GitHub Desktop.
Convert Paxton Fob Data to ids and vice versa
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Paxton Fob converter</title> | |
<style> | |
table, th, td, div { | |
border: 1px solid black; | |
} | |
td { | |
min-width: 100px; | |
} | |
input, select,div, form, table { | |
margin: 5px; | |
padding: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Paxton Fob Conversion</h1> | |
<p> | |
This page can be used to convert the data on a paxton fob to a 8 byte id suitable for emulating as a EM41X id and vice versa. It was written by natmchugh https://github.com/natmchugh. It uses only client side JavaScript and so you can use the page here or save it and run it locally, enjoy! | |
</p> | |
<p> | |
The source code for this page can be found at https://gist.githubusercontent.com/natmchugh/e8f08350a606dc68bbffbc0f6c44017b/raw/paxton-covert.html | |
</p> | |
<div> | |
<h2>Convert page 4 and 5 of data from a paxton tag to an ID</h2> | |
<form onsubmit="convertToEm41x()"> | |
<label for="page4">Page 4:</label><br> | |
<input id="page4"><br> | |
<label for="page5">Page 5:</label><br> | |
<input id="page5"><br> | |
<input type="submit" value="Convert"><br> | |
</form> | |
<table style="border:1px solid black"> | |
<tr> | |
<td>Decimal</td><td id="em41x_dec"></td> | |
</tr> | |
<tr> | |
<td>Hex</td><td id="em41x_hex"></td> | |
</tr> | |
</table> | |
<br/> | |
</div> | |
<div> | |
<h2>Convert from an ID to the equivalent data on page 4 and 5 of a paxton fob</h2> | |
<form onsubmit="convertPaxton()"> | |
<label for="id">Id:</label><br> | |
<input id="id"><br> | |
<label for="type">Type:</label><br> | |
<select id="type"> | |
<option value="6">iso card</option> | |
<option value="3">fob</option> | |
<option value="2">iso magstripe</option> | |
</select><br> | |
<input type="submit" value="Convert"> | |
</form> | |
<table style="border:1px solid black"> | |
<tr> | |
<td>Page 4</td><td id="page4_result"></td> | |
</tr> | |
<tr> | |
<td>Page 5</td><td id="page5_result"></td> | |
</tr> | |
</table> | |
</div> | |
</body> | |
</html> | |
<script> | |
function convertToEm41x() { | |
const page4 = document.getElementById('page4').value.replace(/ /g,''); | |
const page5 = document.getElementById('page5').value.replace(/ /g,''); | |
let hex = BigInt('0x'+page4+page5); | |
let num = i = 0n; | |
let output = 0n; | |
let skip = 64n; | |
let digit = ''; | |
let mask = BigInt('0xF800000000000000'); | |
while (i < 8n) { | |
num = hex & mask; | |
skip -= 5n; | |
mask = mask >> 5n; | |
digit = (num >> skip & 15n); | |
output = (output * 10n ) + digit; | |
if (i === 5n) | |
{ | |
skip -= 2n; | |
mask = mask >> 2n; | |
} | |
i++; | |
} | |
document.getElementById('em41x_dec').innerHTML = (output.toString(10)); | |
document.getElementById('em41x_hex').innerHTML = (output.toString(16)); | |
event.preventDefault(); | |
} | |
function getParity(n) | |
{ | |
return ~(((BigInt(n) * BigInt("0x0101010101010101")) & BigInt("0x8040201008040201")) % BigInt("0x1FF")) & 1n; | |
} | |
function convertPaxton() { | |
event.preventDefault(); | |
const em41x = document.getElementById('id').value.replace(/ /g,'').padStart(8, 0); | |
const type = document.getElementById('type').value; | |
let result = 0n; | |
em41x.split('').forEach( | |
(digit, index) => { | |
dec = BigInt(digit) | |
dec = (getParity(dec) << 4n) + dec; | |
result = (result << 5n) + BigInt(dec); | |
if (index == 5) { result = result << 2n; } | |
} | |
); | |
result = (result << 22n) + 4128768n + BigInt(type); | |
document.getElementById('page4_result').innerHTML = result.toString(16).substr(0, 8); | |
document.getElementById('page5_result').innerHTML = result.toString(16).substr(8, 16); | |
event.preventDefault(); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment