Skip to content

Instantly share code, notes, and snippets.

@raeq
Created July 19, 2020 13:03
Show Gist options
  • Save raeq/bedd9986f04da203a27516dc8c9ce5ac to your computer and use it in GitHub Desktop.
Save raeq/bedd9986f04da203a27516dc8c9ce5ac to your computer and use it in GitHub Desktop.
Encode and Decode base64 strings
import base64
def encode_b64(input_string: str = "") -> object:
return base64.b64encode(input_string.encode("utf-8"))
def decode_b64(input_string: str = "") -> object:
return base64.b64decode(input_string).decode("utf-8")
assert encode_b64("Hello") == b"SGVsbG8="
assert decode_b64(b"SGVsbG8=") == "Hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment