Created
March 13, 2017 19:03
-
-
Save usernaamee/58ca43190885a6aa8fbfa517b7c28291 to your computer and use it in GitHub Desktop.
Create self extracting python 2.6+ source code from any binary file
This file contains 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
""" | |
:| | |
- Email provider doesn't allow me to send certain file types. | |
- I have python installed on all my machines. | |
- Inflates the file size by ~4.5X, still remains under 25M for me. | |
""" | |
from __future__ import print_function | |
import sys | |
inpfile = sys.argv[1] | |
data_ = open(inpfile, "rb").read() | |
byte_array_ = bytearray(data_) | |
print("byte_array_ = bytearray([" + ", ".join([str(b) for b in byte_array_]) + "])") | |
print("open('" + inpfile + "', 'wb').write(byte_array_)") | |
#~~ PS: Improvements and suggestions are welcome! ~~# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment