Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Class for base64 encoding/decoding Action Script?

What would be a best Class for base64 encryption/decryption in Action Script?

like image 796
jayarjo Avatar asked Jul 08 '11 13:07

jayarjo


People also ask

How do I decode a Base64 encoded file?

To decode a file with contents that are base64 encoded, you simply provide the path of the file with the --decode flag. As with encoding files, the output will be a very long string of the original file. You may want to output stdout directly to a file.

How do you decode Base64 encoding in Python?

Base64 Decoding an Image To decode an image using Python, we simply use the base64. b64decode(s) function. Python mentions the following regarding this function: Decode the Base64 encoded bytes-like object or ASCII string s and return the decoded bytes.

How fast is Base64 decoding?

How fast can you decode base64 data? On a recent Intel processor, it takes roughly 2 cycles per byte (from cache) when using a fast decoder like the one from the Chrome browser. This fast decoder is basically doing table lookups.

What is Base64 encoding and decoding?

Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.


1 Answers

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.

like image 86
Corey Avatar answered Sep 26 '22 12:09

Corey