Skip to content

Instantly share code, notes, and snippets.

@blha303
Created August 3, 2019 06:47
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 blha303/2bb974e38b6b80cb1efcd50993ac54bd to your computer and use it in GitHub Desktop.
Save blha303/2bb974e38b6b80cb1efcd50993ac54bd to your computer and use it in GitHub Desktop.
a dumb pair of python scripts to encode/decode files as base64 when dragged or dropped. so i don't have to transfer binary files between servers, just paste into cat <<EOF
#!/usr/bin/env python
from base64 import b64decode
from sys import argv
for fn in argv[1:]:
with open(fn, "rb") as f:
with open(fn[:-4], "wb") as of:
of.write(b64decode(f.read()))
#!/usr/bin/env python
from base64 import b64encode
from sys import argv
for fn in argv[1:]:
with open(fn, "rb") as f:
with open(fn + ".b64", "wb") as of:
of.write(b64encode(f.read()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment