Best Class for base64 encoding/decoding Action Script?
What would be a best Class for 开发者_如何学Gobase64 encryption/decryption in Action Script?
Adobe has two utils for this - Base64Encoder & Base64Decoder. Both are located in the mx.utils package. Although, I had to track them down here - encoder & decoder.
The usage would be something like:
var bmd:BitmapData = myBitmap.bitmapData;
var ba:ByteArray = bmd.getPixels(new Rectangle(0,0,bmd.width,bmd.height));
var b64:Base64Encoder = new Base64Encoder();
b64.encodeBytes(ba);
trace(b64.toString());
Similarly, 'b64.encode' would encode a String rather than a ByteArray.
Both the encoder and decoder add their respective results to an internal buffer. So, you just have to use 'toString' to return the current buffer.
This one seems to have some legs/supporters: http://garry-lachman.com/2010/04/21/base64-encoding-class-in-actionscript-3/
At this link you will find a good Base64 class: http://www.sociodox.com/base64.html
blooddy_crypto
claims (according to it's benchmark) to have a faster base64 encoder/decoder than the mx.utils
one.
Most of the packages that I have seen that include one as a support function use the one that is credited to Steve Webster. I do not know which package this started out in, but it appears in several libraries, including the as3crypto lib on Google Code.
精彩评论