Question
Convert list of ASCII codes to string (byte array) in Python
I have a list of integer ASCII values that I need to transform into a string (binary) to use as the key for a crypto operation. (I am re-implementing java crypto code in python)
This works (assuming an 8-byte key):
key = struct.pack('BBBBBBBB', 17, 24, 121, 1, 12, 222, 34, 76)
However, I would prefer to not have the key length and unpack() parameter list hardcoded.
How might I implement this correctly, given an initial list of integers?
Thanks!