title: Reading base64/zlib encoded string from actionscript in python
body: <p>I have a string saved to a database that is encoded by Actionscript by base64ing it and then zlib compressing it.</p>
  
  <p>An example string is this: "eNrj4mZkrShgWdHBx1mUmJfNosQIACUhBCI="</p>
  
  <p>If I unzip and un base64 this via Actionscript, I get what I expect:</p>
  
  <p>{"xp": 656398, "rank": 34}</p>
  
  <p>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.</p>
  
  <p>So far in Python I have tried this:</p>
  
  <pre><code>import base64
  import zlib
  
  s = 'eNrj4mZkrShgWdHBx1mUmJfNosQIACUhBCI='
  
  print s.decode("base64").decode("zlib")
  </code></pre>
  
  <p>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!</p>
  
  <p>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.</p>