I am not sure how pack("H*" ...) works. According to the docs it seems is generates a string reprensenting the data like how PHP reprensents the data in memory. If you need to do that in another language you need to know exactly what is the transformation of the data here.
Edit: found a hint:
So pack("H", "7") results in 0x70 (ASCII character 'p') and not in 0x07 (BELL character)as well as pack("H*", "347") results in 0x34 ('4') and 0x70 ('p') and not 0x03 and 0x47.






















