binarydata.py 397 B

12345678910111213
  1. # Created: 03.05.2014
  2. # Copyright (c) 2014-2018, Manfred Moitzi
  3. # License: MIT License
  4. from typing import Iterable
  5. from array import array
  6. def binary_encoded_data_to_bytes(data: Iterable[str]) -> bytes:
  7. byte_array = array('B')
  8. for hexstr in data:
  9. byte_array.extend(int(hexstr[index:index+2], 16) for index in range(0, len(hexstr), 2))
  10. return byte_array.tobytes()