Skip to content

Instantly share code, notes, and snippets.

@ctkqiang
Created May 3, 2020 20:11
Show Gist options
  • Save ctkqiang/f3d78f1118f6b373a1051d3aecda8827 to your computer and use it in GitHub Desktop.
Save ctkqiang/f3d78f1118f6b373a1051d3aecda8827 to your computer and use it in GitHub Desktop.
I am so stuck at decoding an encoded image, Mind help?
#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)
@routonmh
Copy link

routonmh commented May 3, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment