Skip to content

Instantly share code, notes, and snippets.

@natmchugh
Last active March 13, 2024 14:30
Show Gist options
  • Save natmchugh/e8f08350a606dc68bbffbc0f6c44017b to your computer and use it in GitHub Desktop.
Save natmchugh/e8f08350a606dc68bbffbc0f6c44017b to your computer and use it in GitHub Desktop.
Convert Paxton Fob Data to ids and vice versa
<!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>
@Rajan244
Copy link

Rajan244 commented Mar 8, 2023

Hi @natmchugh Thank you for your contribution. Could you help to get any Paxton python SDK? I am trying to read RFID tags using Paxton p75 reader .

@natmchugh
Copy link
Author

Hi @natmchugh Thank you for your contribution. Could you help to get any Paxton python SDK? I am trying to read RFID tags using Paxton p75 reader .

AFAIK the P75 reader is made to be plugged into a paxton board and speaks a proprietary protocol . However I believe you can get them to speak the common Wiegand protocol with an activation card. There will be stuff in python for understanding Wiegand.

@Rajan244
Copy link

Rajan244 commented Mar 8, 2023

Hi @natmchugh appreciate your quick response. I am trying read using Wiegand protocol but instead of response page 4 or 5 , m receiving 8 characters string like 'F33C9E67'. here is code https://github.com/Rajan244/RFID/blob/main/wiegand.py ,

  • how could received the response with page 4 - 5 ?
  • what is the role of activation card here ?
    many thanks.

@natmchugh
Copy link
Author

At a guess the string F33C9E67 converts to paxton id 4080836199 which you can convert to here https://badcfe.org/paxton-covert to Page 4 90441132
Page 5 c1ce7f0006

@Rajan244
Copy link

Rajan244 commented Mar 9, 2023

Thank you for comment @natmchugh, actually the tag contains 29714856 value, don't know how can I fetch direct id/page 4-5/ hex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment