Skip to content

Instantly share code, notes, and snippets.

@avsmithy
Forked from natmchugh/paxton-covert.html
Created September 28, 2022 20:42
Show Gist options
  • Select an option

  • Save avsmithy/c7d889e767a4b0c46aa9bb1fcfed3f4c to your computer and use it in GitHub Desktop.

Select an option

Save avsmithy/c7d889e767a4b0c46aa9bb1fcfed3f4c to your computer and use it in GitHub Desktop.

Revisions

  1. @natmchugh natmchugh revised this gist Sep 20, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paxton-covert.html
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ <h1>Paxton Fob Conversion</h1>
    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.github.com/natmchugh/e8f08350a606dc68bbffbc0f6c44017b/raw/paxton-covert.html](https://gist.github.com/natmchugh/e8f08350a606dc68bbffbc0f6c44017b/raw/paxton-covert.html)
    The source code for this page can be found at https://gist.github.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>
  2. @natmchugh natmchugh revised this gist Sep 20, 2022. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion paxton-covert.html
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,9 @@ <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.github.com/natmchugh/e8f08350a606dc68bbffbc0f6c44017b/raw/paxton-covert.html](https://gist.github.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()">
  3. @natmchugh natmchugh revised this gist Sep 19, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions paxton-covert.html
    Original file line number Diff line number Diff line change
    @@ -69,7 +69,7 @@ <h2>Convert from an ID to the equivalent data on page 4 and 5 of a paxton fob</h
    </body>
    </html>

    <script src="/convert.js">
    <script>
    function convertToEm41x() {
    const page4 = document.getElementById('page4').value.replace(/ /g,'');
    const page5 = document.getElementById('page5').value.replace(/ /g,'');
    @@ -103,8 +103,8 @@ <h2>Convert from an ID to the equivalent data on page 4 and 5 of a paxton fob</h

    function convertPaxton() {
    event.preventDefault();
    const em41x = document.getElementById('id').value.replace(/ /g,'');
    const type = document.getElementById('type').value.replace(/ /g,'');
    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) => {
  4. @natmchugh natmchugh revised this gist Sep 19, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions paxton-covert.html
    Original file line number Diff line number Diff line change
    @@ -21,11 +21,11 @@
    <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 you are welcome to save the page and run it locally.
    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>

    <div>
    <h2>Convert page 4 and 5 of data from a paxrton tag to an ID</h2>
    <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>
    @@ -45,7 +45,7 @@ <h2>Convert page 4 and 5 of data from a paxrton tag to an ID</h2>
    </div>

    <div>
    <h2>Convert from an ID to the equivalent data on page 4 and 5 of paxton fob</h2>
    <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>
  5. @natmchugh natmchugh renamed this gist Sep 19, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. @natmchugh natmchugh created this gist Sep 19, 2022.
    124 changes: 124 additions & 0 deletions html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,124 @@
    <!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 you are welcome to save the page and run it locally.
    </p>

    <div>
    <h2>Convert page 4 and 5 of data from a paxrton 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 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 src="/convert.js">
    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,'');
    const type = document.getElementById('type').value.replace(/ /g,'');
    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>