com.infoengine.util
Class Base64

java.lang.Object
  extended bycom.infoengine.util.Base64

public class Base64
extends Object

Utility class providing static methods for encoding and decoding data using the Base64 algorithm specified in Internet Standard RFC2045.


Field Summary
private static byte[] Base64DecMap
           
private static byte[] Base64EncMap
           
 
Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(byte[] encoded)
          Decode a Base64-encoded byte array containing single-byte characters from the Base64 alphabet.
static byte[] decode(byte[] encoded, int offset, int len)
          Decode a subset of a Base64-encoded byte array containing single-byte characters from the Base64 alphabet.
static String decode(String base64str)
          Decode a Base64-encoded string.
static byte[] encode(byte[] bytes)
          Base64-encode an array of bytes.
static String encode(String str)
          Base64-encode a string.
private static byte[] fromBytes(byte[] encoded, int offset, int len)
           
private static byte[] toBytes(byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Base64EncMap

private static byte[] Base64EncMap

Base64DecMap

private static byte[] Base64DecMap
Constructor Detail

Base64

public Base64()
Method Detail

decode

public static final String decode(String base64str)
Decode a Base64-encoded string. This method should be called only when it is known that the decoded result will be a valid string and not binary data.

Parameters:
base64str - The Base64-encoded string.
Returns:
The decoded result.

decode

public static final byte[] decode(byte[] encoded)
Decode a Base64-encoded byte array containing single-byte characters from the Base64 alphabet.

Parameters:
encoded - The Base64-encoded array of single-byte characters.
Returns:
The decoded result.

decode

public static final byte[] decode(byte[] encoded,
                                  int offset,
                                  int len)
Decode a subset of a Base64-encoded byte array containing single-byte characters from the Base64 alphabet.

Parameters:
encoded - The Base64-encoded array of single-byte characters.
offset - The index of the first character to be decoded.
len - The number of characters to be decoded.
Returns:
The decoded result.

encode

public static final byte[] encode(byte[] bytes)
Base64-encode an array of bytes.

Parameters:
bytes - The array of bytes to be encoded.
Returns:
The Base64-encoded result, as an array of single-byte characters from the Base64 alphabet.

encode

public static final String encode(String str)
Base64-encode a string.

Parameters:
str - The string to be encoded.
Returns:
The Base64-encoded result, as a string.

fromBytes

private static final byte[] fromBytes(byte[] encoded,
                                      int offset,
                                      int len)

toBytes

private static final byte[] toBytes(byte[] data)