Wednesday, July 9, 2014

Encodings (personal notes)

This is not supposed to be pretty, just for me:

ENCODINGS N' SHIT

From hex to string
print("\x41") #will print "A" since 41 is the hex of capital A
  A

From string to hex
"A".encode("hex")
  41

From hex to string (again)
"41".decode("hex")
  A

  encoder/decode supports hex, base64, utf-8, rot13, and a bunch others (https://docs.python.org/2/library/codecs.html#standard-encodings)

URL encode:
import urllib
urllib.quote_plus("HOLA\":!@$")
  HOLA%22%3A%21%40%24

No comments:

Post a Comment