Posted By

lorenz82 on 11/15/10


Tagged

base64 as3 compress uncompress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

lorenz82
thastyle


base64 Compress/Uncompress


 / Published in: ActionScript 3
 

  1. import mx.utils.Base64Encoder;
  2. import mx.utils.Base64Decoder;
  3.  
  4. // Compress a ByteArray into a Base64 String.
  5. function compress(bytes:ByteArray):String {
  6. var enc:Base64Encoder = new Base64Encoder();
  7. enc.encodeBytes(bytes);
  8. return enc.drain().split("\n").join("");
  9. }
  10.  
  11. // Uncompress a Base64 String into a ByteArray.
  12. function uncompress(str:String):ByteArray {
  13. var dec:Base64Decoder = new Base64Decoder();
  14. dec.decode(str);
  15. var newByteArr:ByteArray=dec.toByteArray();
  16. return newByteArr;
  17. }

Report this snippet  

You need to login to post a comment.