Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Base64 file encoder and decoder.
#!/usr/bin/env python3
import base64
import sys
if __name__ == "__main__":
if sys.argv[1] == "e":
base64_function = base64.b64encode
elif sys.argv[1] == "d":
base64_function = base64.b64decode
with open(sys.argv[2], "rb") as f:
input_content = f.read()
with open(sys.argv[3], "wb") as f:
f.write(base64_function(input_content))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.