public class Base64
extends java.lang.Object
This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.
Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).
Constructor and Description |
---|
Base64()
Creates a Base64 codec.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(byte[] pArray)
Decodes a byte[] containing containing characters in the Base64 alphabet.
|
byte[] |
decode(java.lang.String pArray)
Decodes a String containing containing characters in the Base64 alphabet.
|
static byte[] |
decodeBase64(byte[] base64Data)
Decodes Base64 data into octets
|
static byte[] |
decodeBase64(java.lang.String base64String)
Decodes a Base64 String into octets
|
byte[] |
encode(byte[] pArray)
Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
|
static byte[] |
encodeBase64(byte[] binaryData)
Encodes binary data using the base64 algorithm.
|
static java.lang.String |
encodeBase64String(byte[] binaryData)
Encodes binary data using the base64 algorithm.
|
static boolean |
isBase64(byte octet)
Returns whether or not the
octet is in the base 64 alphabet. |
public static boolean isBase64(byte octet)
octet
is in the base 64 alphabet.octet
- The value to testtrue
if the value is defined in the the base 64 alphabet, false
otherwise.public static java.lang.String encodeBase64String(byte[] binaryData)
binaryData
- binary data to encodepublic static byte[] encodeBase64(byte[] binaryData)
binaryData
- Array containing binary data to encode.java.lang.IllegalArgumentException
- Thrown when the input array needs an output array bigger than maxResultSizepublic static byte[] decodeBase64(java.lang.String base64String)
base64String
- String containing Base64 datapublic static byte[] decodeBase64(byte[] base64Data)
base64Data
- Byte array containing Base64 datapublic byte[] decode(java.lang.String pArray)
pArray
- A String containing Base64 character datapublic byte[] decode(byte[] pArray)
pArray
- A byte array containing Base64 character datapublic byte[] encode(byte[] pArray)
pArray
- a byte array containing binary data