I have extracted base64 string of forecolor, texture and edgemap values of images, I have a list with following structure:
forecolor=AgCEAg4DUQQCBQQGARMBFQE1AmUB
edge=AfCAFg5iIATCPwTAEIiBFggBDw
forecolor=AgAsAQ0CJAMcDRgOGg8DHQYeBzYBPQ4-DU0ETgNtBm4CfQI
I am trying to decode these values, but I am getting Incorrect Padding error, here is the exact error:
Traceback (most recent call last):
File "ImageVectorData.py", line 44, in <module>
print "Decoded String: " + decoded.decode('base64', 'strict')
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/base64_codec.py", line 42, in base64_decode
output = base64.decodestring(input)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 321, in decodestring
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
Here is my code:
for item in value:
print "String before Split: " + item
if item.split("=")[0] == "forecolor":
decoded = (item.split("=")[1])
print "String to be decoded: " + decoded
print "Decoded String: " + decoded.decode('base64', 'strict')
I also saw an interesting out put when the first forecolor base64 string got decoded: Here is the out put of that:
String before Split: forecolor=AgCEAg4DUQQCBQQGARMBFQE1AmUB
String to be decoded: AgCEAg4DUQQCBQQGARMBFQE1AmUB
Decoded String: ?Q5e
I am not really sure what I am doing wrong here. I looked at following python document and tried that but that didn't work either: http://docs.python.org/library/base64.html