base64 Compress/Uncompress


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.