Created
May 3, 2020 20:11
-
-
Save ctkqiang/f3d78f1118f6b373a1051d3aecda8827 to your computer and use it in GitHub Desktop.
I am so stuck at decoding an encoded image, Mind help?
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
#encoder: | |
import base64 | |
_userOriginalBinaryfile = input("Please Enter the Location of the file design to encrypt: ") | |
with open(_userOriginalBinaryfile, "rb") as _inputFile: | |
_input_file_data = _inputFile.read() | |
_encodeData = base64.b64encode(_input_file_data) | |
_encodeMessage = _encodeData.decode("utf-8") | |
print(_encodeMessage) | |
## decoder: | |
import base64 | |
_encryptedBinaryData = input("Please Enter The {encryptedBinaryData} for decryption: ") | |
_base64_binary_bytes = _encryptedBinaryData.encode("utf-8") | |
with open("_decoded_Binary_data.png", "wb") as _saveFile: #Change Extension as wish | |
_decoded_data = base64.decodebytes(bytes(_base64_binary_bytes)).strip() #<------------this gave me exception "incorrect padding" | |
_saveFile.write(_decoded_data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: https://gist.github.com/routonmh/2c3486ad33195bc80ea2d6805a3bdd2d