Created
October 3, 2017 23:44
-
-
Save xtornasol512/6e5acfaabc32ecdaa8a35df172f717c8 to your computer and use it in GitHub Desktop.
Convert any file to base64 using base64 python standard library
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
''' Convert any file to base64 using base64 python standard library ''' | |
import base64 | |
with open('MyFile.ext', 'rb') as f: | |
# read file as binary and encode to base64 | |
encoded_string = base64.b64encode(f.read()) | |
with open('cer.base64', 'w') as f: | |
# write in a new file the base64 | |
f.write(encoded_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment