Expresso 5-5-0

com.jcorporate.expresso.core.misc
Class Base64

java.lang.Object
  extended bycom.jcorporate.expresso.core.misc.Base64

public class Base64
extends Object

Base 64 encoding class. Many thanks goes to Wei Dai's Crypto++ for providing public domain C++ code that this could be derived from.

Since:
Expresso 3.0

Constructor Summary
Base64()
           
 
Method Summary
static byte[] decode(String data)
          decode - Decodes a Base64 encoded string back into its original binary format.
static byte[] decodeNoPadding(String data)
          Note: this function does not process stricly compliant Base64 code.
static String encode(byte[] inBuffer)
          encode - Encodes a binary byte array into an Ascii String (including 80 column line wrap.
static String encodeNoPadding(byte[] inBuffer)
          Note: this function does not process stricly compliant Base64 code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Base64

public Base64()
Method Detail

decode

public static byte[] decode(String data)
                     throws IllegalArgumentException
decode - Decodes a Base64 encoded string back into its original binary format. If the data is not a proper base64 encoded string, it might throw an ArrayIndexOutOfBoundsException.

Parameters:
data - the data to decode
Returns:
Throws:
IllegalArgumentException

decodeNoPadding

public static byte[] decodeNoPadding(String data)
                              throws IllegalArgumentException
Note: this function does not process stricly compliant Base64 code. To process strictly compliant Base64 encoded strings, use encode and decode functions with padding Decodes a Base64 encoded string back into its original binary format. The only difference from decode is that this function will bad the end with as many ='s as necessary to make things work properly.

Parameters:
data - the Base64 encoded string
Returns:
the byte array of the original data.
Throws:
IllegalArgumentException - if the input data is null or zero bytes.

encode

public static String encode(byte[] inBuffer)
                     throws IllegalArgumentException
encode - Encodes a binary byte array into an Ascii String (including 80 column line wrap.

Returns:
Throws:
IllegalArgumentException

encodeNoPadding

public static String encodeNoPadding(byte[] inBuffer)
                              throws IllegalArgumentException
Note: this function does not process stricly compliant Base64 code. To process strictly compliant Base64 encoded strings, use encode and decode functions with padding Encodes a binary bite array into Base64 coding. The difference between this and the other encode function, is that this function strips all padding from the final result before returning

Returns:
a string that is the Base64 equiv of the input data without padding characters
Throws:
IllegalArgumentException - if the input data is null or zero bytes.

Expresso 5-5-0

Please see www.jcorporate.com for information about new Expresso releases.