>>> packHex "48656c6c6f2c20776f726c642e" "Hello, world."Leading zeros can be omitted, i.e. it's unnecessary to pad the input to an even number of bytes:
>>> packHex "0" "\NUL"
"3adf91c0" ==> B.pack [0x3a, 0xdf, 0x91, 0xc0]Strings of odd length will cause an exception as will non-hex characters such as '0x'.