Add some byte conversion utilities

pull/8/head
Nicolas Jouanin 2015-05-28 23:17:25 +02:00
rodzic 35577ab99a
commit 2b45fc6a3e
1 zmienionych plików z 10 dodań i 0 usunięć

10
hbmqtt/utils.py 100644
Wyświetl plik

@ -0,0 +1,10 @@
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.
def bytes_to_hex_str(data):
return '0x' + ''.join(format(b, '02x') for b in data)
def hex_to_int(data):
return int.from_bytes(data, byteorder='big')