Skip to content

Instantly share code, notes, and snippets.

@binary10
Last active October 7, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binary10/c6641131af9cf00ae267dc21a58db213 to your computer and use it in GitHub Desktop.
Save binary10/c6641131af9cf00ae267dc21a58db213 to your computer and use it in GitHub Desktop.
import base64
# Create a string and encode to bytes
s = 'Convert me to base64!'
sb = s.encode('utf-8')
# Take bytes and encode to base64 string
sb64 = base64.b64encode(sb).decode()
# Q29udmVydCBtZSB0byBiYXNlNjQh
# Take base64 string and decode back to original string
base64.b64decode(sb64).decode('utf-8')
# 'Convert me to base64!'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment