Skip to content

Instantly share code, notes, and snippets.

@zzj0402
Created May 7, 2019 00:26
Show Gist options
  • Save zzj0402/f4ad56de2f2c4f542aafd9f685aec250 to your computer and use it in GitHub Desktop.
Save zzj0402/f4ad56de2f2c4f542aafd9f685aec250 to your computer and use it in GitHub Desktop.
Open and store images with base64 encoding
import base64
with open("D:\\cyber-security\\Assignment3\\t.png", "rb") as imageFile:
str = base64.b64encode(imageFile.read())
print(str)
fh = open("D:\\cyber-security\\Assignment3\\s.png", "wb")
decoded = base64.b64decode(str)
fh.write(decoded)
fh.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment