im = Image.open(filePath) # load image
self.msg = str(bytearray(list(im.getdata()))) # convert image data to string
encodedMsg = base64.b64encode(self.msg)
when I was trying to encode the data read from an image to base64, it returns an error:
File "Steganography.py", line 42, in msgToXml
encodedMsg = base64.b64encode(self.msg)
File "/opt/python3/current/lib/python3.4/base64.py", line 62, in b64encode
encoded = binascii.b2a_base64(s)[:-1]
TypeError: 'str' does not support the buffer interface
It works when I'm home using Ubuntu(python 2.7). But it shows error when I use school machine(python3.4). How can I solve this?
encodedMsg = base64.b64encode(self.msg.encode('ascii'))
reference: Base64 encoding in Python 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With