Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iomonad/df1f3cacdf16c13d859bed41a9684ffe to your computer and use it in GitHub Desktop.
Save iomonad/df1f3cacdf16c13d859bed41a9684ffe to your computer and use it in GitHub Desktop.

Revisions

  1. @atc1441 atc1441 revised this gist Jul 18, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Philips Sonicare NFC Password generation
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #include <stdio.h>
    #include <stdint.h>
    // Philips Sonicare NFC Head Password calculation by @atc1441
    // Philips Sonicare NFC Head Password calculation by @atc1441 Video manual: https://www.youtube.com/watch?v=EPytrn8i8sc
    uint16_t CRC16(uint16_t crc, uint8_t *buffer, int len) // Default CRC16 Algo
    {
    while(len--)
  2. @atc1441 atc1441 created this gist Jun 9, 2023.
    36 changes: 36 additions & 0 deletions Philips Sonicare NFC Password generation
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #include <stdio.h>
    #include <stdint.h>
    // Philips Sonicare NFC Head Password calculation by @atc1441
    uint16_t CRC16(uint16_t crc, uint8_t *buffer, int len) // Default CRC16 Algo
    {
    while(len--)
    {
    crc ^= *buffer++ << 8;
    int bits = 0;
    do
    {
    if ( (crc & 0x8000) != 0 )
    crc = (2 * crc) ^ 0x1021;
    else
    crc *= 2;
    }
    while ( ++bits < 8 );
    }
    return crc;
    }

    uint8_t nfctag_uid[] = {0x04,0xEC,0xFC,0xA2,0x94,0x10,0x90}; // NTAG UID
    uint8_t nfc_second[] = "221214 12K"; // Head MFG String, printed on Head and at memory location 0x23

    int main()
    {
    uint32_t crc_calc = CRC16(0x49A3, nfctag_uid, 7); // Calculate the NTAG UID CRC

    crc_calc = crc_calc | (CRC16(crc_calc, nfc_second, 10) << 16); // Calculate the MFG CRC

    crc_calc = (crc_calc >> 8) & 0x00FF00FF | (crc_calc << 8) & 0xFF00FF00; // Rotate the uin16_t bytes

    printf("by @ATC1441 NFC CRC : 0x%08X expected: 0x61F0A50F\r\n", crc_calc);// Print out the calucated password

    return 0;
    }