Created
August 22, 2021 03:40
-
-
Save FerdinaKusumah/2a23114234991dfbd1b89ec13864dc1e to your computer and use it in GitHub Desktop.
Run Python from compile file
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
import base64 | |
""" | |
step 1. python -m compileall app.py | |
step 2. run python with compiled files | |
python __pycache__/app.cpython-39.pyc | |
""" | |
def encode_message(msg): | |
return base64.b64encode(msg.encode('ascii')).decode('ascii') | |
def decode_message(msg): | |
return base64.b64decode(msg).decode('ascii') | |
message = "Python is fun" | |
base64_message = encode_message(message) | |
plain_message = decode_message(base64_message) | |
if __name__ == "__main__": | |
print(base64_message) | |
print(plain_message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment