I'm trying to assemble a byte array in Python for a signature that resembles the following:
- 4 bytes that represent the length, in bytes, of String A.
- String A
- 4 bytes that represent the length, in bytes, of String B.
- String B
- 4 bytes that represent the length, in bytes, of the Long A value.
- Long A
String A + B are utf-8 which I converted to utf-8 using unicode(string, 'utf-8')
I've tried converting each item to a byte array and joining them using the plus symbol e.g.
bytearray(len(a)) + bytearray(a, "utf-8")...
I've also stried using struct.pack e.g.
struct.pack("i", len(a)) + bytearray(access_token, "utf-8")...
But nothing seems to generate a valid signature. Is this the right way to make the above byte array in Python?