Skip to content

Instantly share code, notes, and snippets.

@decidedlygray
Created December 14, 2017 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save decidedlygray/a037a52ead8652dc2887358081ab11cd to your computer and use it in GitHub Desktop.
Save decidedlygray/a037a52ead8652dc2887358081ab11cd to your computer and use it in GitHub Desktop.
Python2 snippet for taking a base64-encoded unicode string, and decoding it properly so there aren't trailing null bytes on ASCII characters
#!/usr/bin/env python
"""
Python2 snippet for taking a base64-encoded unicode string, decoding it
properly so there aren't trailing null bytes for ASCII characters
Leaving this here so I don't have to look it up again
@decidedlygray
"""
import base64
b64_str = "ADD BASE64 UNICODE STRING HERE"
b64_str_decoded = base64.b64decode(b64_str).decode('UTF-16')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment