Packageimpression.utilities
Classpublic class Base64
InheritanceBase64 Inheritance Object

The Base64 class provides routines for encoding and decoding items to the Base64 format.

Some of the algorithms used here are based on code from the AS3 Crypto library, located at http://code.google.com/p/as3crypto



Public Properties
 PropertyDefined By
  codePage : String
[static] Identifies the code page to use when decoding non-UTF8 strings containing "high ascii" characters.
Base64
Public Methods
 MethodDefined By
  
decodeToByteArray(base64String:String):ByteArray
[static] Decodes a Base64-encoded string and returns the result.
Base64
  
decodeToString(base64String:String, decodeAsUTF:Boolean = true):String
[static] Decodes a Base64-encoded string and returns the string result.
Base64
  
encode(source:*):String
[static] Returns a Base64-encoded string.
Base64
Property Detail
codePageproperty
codePage:String

Identifies the code page to use when decoding non-UTF8 strings containing "high ascii" characters. The empty string ("") specifies the default code page for the system.

The default value is "".


Implementation
    public static function get codePage():String
    public static function set codePage(value:String):void
Method Detail
decodeToByteArray()method
public static function decodeToByteArray(base64String:String):ByteArray

Decodes a Base64-encoded string and returns the result.

Parameters

base64String:String — The string to decode.

Returns
ByteArray — A ByteArray containing the decoded data from base64String.
decodeToString()method 
public static function decodeToString(base64String:String, decodeAsUTF:Boolean = true):String

Decodes a Base64-encoded string and returns the string result.

This method invokes the decodeToByteArray method and then returns the result of calling a string conversion method on the resulting ByteArray.

Parameters

base64String:String — The string to decode.
 
decodeAsUTF:Boolean (default = true) — An optional boolean expression specifying how the decoded ByteArray should be converted to a String. If this value is true (the default), the readUTFBytes method will be used to convert the ByteArray to a String. If this value is false, the readMultiByte method will be used for conversion. Note that in the second case, the value of the codePage property is used to determine how to process "high ascii" characters.

Returns
String — A string containing the decoded data from base64String.

See also

encode()method 
public static function encode(source:*):String

Returns a Base64-encoded string.

Parameters

source:* — Expression identifying the item to encode. source can be one of the following types:
  • null. The method returns the empty string ("").
  • String. The method creates a new ByteArray object and uses the writeUTFBytes method to read the string into the ByteArray. The resulting object is encoded.
  • ByteArray. The method returns an encoded version of the object.

Returns
String — A String containing the Base64-encoded data from source.