Skip to content

Instantly share code, notes, and snippets.

@pixdoet
Created March 16, 2022 08:24
Show Gist options
  • Save pixdoet/8f84fa76592462f3345b5c3944198886 to your computer and use it in GitHub Desktop.
Save pixdoet/8f84fa76592462f3345b5c3944198886 to your computer and use it in GitHub Desktop.
Python script to convert any file to a base64 string.
import base64
filename = input("Enter file location: ")
with open(filename, "rb") as f:
data = f.read()
base64_1 = base64.encodestring(data)
with open("output.txt", "w") as w:
w.write(base64_1.decode("ascii"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment