org.opennms.core.utils
Class Base64

java.lang.Object
  extended by org.opennms.core.utils.Base64

public final class Base64
extends Object

Performs base 64 encoding and decoding on byte arrays.

Version:
CVS 1.1.1.1
Author:
Brian Weaver , OpenNMS , Brian Weaver , OpenNMS

Method Summary
static byte[] decodeBase64(char[] data)
           Decodes a character array into the corresponding byte array.
static char[] encodeBase64(byte[] data)
           Encodes the passed byte array using the base64 rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeBase64

public static char[] encodeBase64(byte[] data)

Encodes the passed byte array using the base64 rules. The base64 encoding schema is performed by grouping the bytes in to 6-bit quantities and then encoding them.

For more information see RFC1341 for the format used for base64 encoding.

Parameters:
data - The input byte array
Returns:
The converted data in a character stream.

decodeBase64

public static byte[] decodeBase64(char[] data)

Decodes a character array into the corresponding byte array. The buffer must be an intergral number of 4 character. I.E. size mod 4 is equal to zero or an exception will be thrown. Likewise, if there is an invalid character in the input array then an exception will be thrown.

Parameters:
data - The data stream to be filtered.
Returns:
The coverted array of bytes.
Throws:
IllegalArgumentException - Thrown if an invalid buffer that cannot be decoded is passed.


Copyright © 2011. All Rights Reserved.