Ver originaldef to_bytearray(some_int): x = hex(some_int)[2:] if len(x) % 2 == 1: x = '0' + x return bytearray.fromhex(x)