I have a string saved to a database that is encoded by Actionscript by base64ing it and then zlib compressing it.
An example string is this: “eNrj4mZkrShgWdHBx1mUmJfNosQIACUhBCI=”
If I unzip and un base64 this via Actionscript, I get what I expect:
{“xp”: 656398, “rank”: 34}
But, I need to be able to also read this server-side. For now I’m using Python but I’d be open to a working PHP solution or similar.
So far in Python I have tried this:
import base64
import zlib
s = 'eNrj4mZkrShgWdHBx1mUmJfNosQIACUhBCI='
print s.decode("base64").decode("zlib")
It looks like Actionscript adds some extra bits into the header, but my Python is not strong enough to defeat this 🙂 Any help would be much appreciated!
EDIT: Actionscript first takes an AS Object and converts it to a ByteArray, before zlib compressing it and base64ing it. It looks like this is what is generating the extra header/mangled data info.
Flash could be mangling this, but you should share an example from Actionscript that creates and checks this data.
If you’re using a 3rd party library, it might be using an alternate characterset than Python is expecting.
if you’re using the official library, it seems that Actionscript implements UTF8 and ascii differently. ( there are different methods here – http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/utils/Base64Encoder.html)
it’s much easier to just see the actionscript and note if there’s an issue with the library or your code, than try to reverse engineer this.
I think it also might be worth trying to bugfix this in reverse…
Can I also ask why you’re even doing this ?
1- unless your packets are much bigger, you’re not going to be saving much bandwidth. in fact, compression on small payloads can actually increase the size.
2- assuming this is web based, you should be able to have the server do this on the fly.