def key_handle_to_int(this):
try:<EOL><INDENT>num = int(this)<EOL>return num<EOL><DEDENT>except ValueError:<EOL><INDENT>if this[:<NUM_LIT:2>] == "<STR_LIT>":<EOL><INDENT>return int(this, <NUM_LIT:16>)<EOL><DEDENT>if (len(this) == <NUM_LIT:4>):<EOL><INDENT>num = struct.unpack('<STR_LIT>', this)[<NUM_LIT:0>]<EOL>return num<EOL><DEDENT><DEDENT>raise pyhsm.exception.YHSM_Error("<STR_LIT>" % (this))<EOL>
Turn "123" into 123 and "KSM1" into 827151179
(0x314d534b, 'K' = 0x4b, S = '0x53', M = 0x4d).

YHSM is little endian, so this makes the bytes KSM1 appear
in the most human readable form in packet traces.