Skip to content

Instantly share code, notes, and snippets.

View ebarojas's full-sized avatar
🔭

Everardo J. Barojas M. ebarojas

🔭
View GitHub Profile
#!/usr/bin/env python
#
# Electrum - lightweight Bitcoin client
# Copyright (C) 2011 thomasv@gitorious
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
@xtornasol512
xtornasol512 / AnyFile2base64.py
Created October 3, 2017 23:44
Convert any file to base64 using base64 python standard library
''' 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)