Python base64 string decoding

I have what should be an UCS-2 encoded XML document that I was able to create a mini-disk based DOM after some setup.

The problem is that I must have some base64 encoded data. I know that:

AME= (or \x00A\x00M\x00E\x00=) is base64 code for Á

How do I decode this?

http://www.fileformat.info/info/unicode/char/00c1/index.htm shows that the unicode representation for Á: u is "\ u00C1" and in UTF-16: 0x00C1

base64.b64decode('AME=').decode('UTF-16')

shows

u'\uc100'

like a unicode representation for a character, but it looks like a byte.

Any idea on how to decode it?

+5
source share
1 answer

check this

>>> import base64
>>> base64.b64decode('AME=').decode('UTF-16')
u'\uc100'
>>> base64.b64decode('AME=').decode('UTF-16LE')  
u'\uc100'
>>> base64.b64decode('AME=').decode('UTF-16BE')
u'\xc1'

Perhaps you are looking for a big end decryption?

+11
source

All Articles