Created
July 19, 2020 13:03
-
-
Save raeq/bedd9986f04da203a27516dc8c9ce5ac to your computer and use it in GitHub Desktop.
Encode and Decode base64 strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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