-
-
Save LucaBongiorni/c9b4c342618b2f30d31f1930d3316c86 to your computer and use it in GitHub Desktop.
A quick and dirty Jupyter notebook to convert BLEKey data to cards.
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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 26, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Number of cards: 4\n", | |
"0. 26 bit card: 0x200615afef\n", | |
"1. 26 bit card: 0x20042ae799\n", | |
"2. 26 bit card: 0x20042ae799\n", | |
"3. 26 bit card: 0x200615afef\n" | |
] | |
} | |
], | |
"source": [ | |
"# paste the hex string from your BLE client log here \n", | |
"cards = \"1aefaf15 0620001a 99e72a04 20001a99 e72a0420 001aefaf 15062000\"\n", | |
"\n", | |
"# Convert hex string to bytes\n", | |
"cards = cards.replace(\" \", \"\")\n", | |
"cards = bytearray.fromhex(cards)\n", | |
"\n", | |
"num_cards = len(cards) // 7\n", | |
"\n", | |
"print(\"Number of cards: \" + str(num_cards))\n", | |
"\n", | |
"for i in range(0, num_cards):\n", | |
" start = i * 7\n", | |
" print (\"%d. %d bit card: \" % (i, cards[start]), end=\"\")\n", | |
" card_data = reversed(cards[start + 1:start + 6])\n", | |
" fixed = ''.join('{:02x}'.format(x) for x in card_data)\n", | |
" print (\"0x%s\" % fixed)\n", | |
" fixed = None\n", | |
" card_data = None" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment