MCPcopy Create free account
hub / github.com/PiLiDAR/PiLiDAR / bytes_from_hex

Function bytes_from_hex

lib/binary_utils.py:15–24  ·  view source on GitHub ↗

Return the binary data represented by the hexadecimal string. Every 2-digit hex representation is converted into the corresponding byte of data. The resulting byte string is therefore half as long as the hex string.

(hex_string, spaced=False)

Source from the content-addressed store, hash-verified

13 return hex_string
14
15def bytes_from_hex(hex_string, spaced=False):
16 """Return the binary data represented by the hexadecimal string. Every 2-digit hex representation
17 is converted into the corresponding byte of data. The resulting byte string is therefore half as long as the hex string.
18 """
19 if spaced:
20 hex_string = ''.join(hex_string.split(' '))
21
22 byte_string = binascii.unhexlify(hex_string)
23
24 return byte_string
25
26def shift_bytes(data, shift=1):
27 return data[-shift:] + data[:-shift]

Callers 1

binary_utils.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected