Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


text to hex and ASCII
by admin
 at 2017-04-09 02:24:00.

this code will input some text and give you the hex and ASCII characters
#!/usr/bin/env python
#a wile loop (if true continue to redo until false)
while True:
   stringName = raw_input("Convert string to hex & ascii(type exit to quit): ").strip()
   if stringName == 'exit':
      break
   #encode is a built it python function ex: "d".encode('hex') = 64
   print "Hex value: ", stringName.encode('hex') 
   #ord is a built it python function that wil convert text to ascii ex ord('d') = 100
   print "ASCII value: ", ', '.join(str(ord(c)) for c in stringName)