Data packet analysis ascii transcoding operation method

For data packet analysis ascii transcoding operation methods, please see the python source code example below. Convert ASCII to hexadecimal, which is convenient for applications that analyze data packets.

#!/usr/bin/env python
#www.iplaypy.com
 
import sys
 
if __name__ == '__main__':
     
    string = sys.argv[1] 
    aDict = {}
 
    for c in string:
        asi = hex(ord(c))
        aDict[c] = asi
 
    for key in aDict:
        print key, aDict[key]

Guess you like

Origin blog.csdn.net/lmrylll/article/details/131980746