public class Base64
extends Object
We specifically do NOT use the infamous sun.misc.BASE64Encoder() and sun.misc.BASE64Decoder() classes, rather we rely on our own, carefully optimized, 100% pure Java code.
Modifier and Type | Field and Description |
---|---|
static String |
VERSION
Version number of this Package (read-only).
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(byte... data)
Decodes a Base64-encoded byte array.
|
static byte[] |
decode(String data)
Decodes a Base64-encoded string.
|
static String |
encode(byte... data)
Encodes a byte array to a Base64 string, comprised of characters within a
6-bit range, mainly for the purpose of accurate transmission of 8-bit data
over [typically older] 7-bit communications protocols without sacrificing
data integrity.
|
static String |
encode(String data)
Encodes a String to a Base64 string, comprised of characters within a
6-bit range, mainly for the purpose of accurate transmission of 8-bit data
over [typically older] 7-bit communications protocols without sacrificing
data integrity.
|
static byte[] |
sloppyDecode(byte... data)
Decodes a Base64-encoded byte array, while also ignoring all padding
(equal signs -- "=") and invalid characters (useful when attempting to
recover from data corruption), which is why we call it a "sloppy decode."
|
static byte[] |
sloppyDecode(String data)
Decodes a Base64-encoded String, while also ignoring all padding (equal
signs -- "=") and invalid characters (useful when attempting to recover
from data corruption), which is why we call it a "sloppy decode."
|
public static final String VERSION
public static byte[] decode(byte... data) throws java.text.ParseException
This method produces a byte array containing 8-bit bytes.
data
- The byte array containing Base64-encoded data to be decoded (if
the array is empty, an empty array will simply be returned)java.text.ParseException
- When an invalid character other than
white space or newline characters is encounteredpublic static byte[] decode(String data) throws java.text.ParseException
This method produces a byte array containing 8-bit bytes.
data
- The String containing Base64-encoded data to be decoded (if the
string is empty, an empty array will simply be returned)java.text.ParseException
- When an invalid character other than
white space or newline characters is encounteredpublic static String encode(byte... data)
This method produces a string containing only valid characters from the Base64 alphabet. No white space characters are added, especially including trailing newline characters (which some base 64 encoding routines have been found to include, sometimes intermittently).
We specifically do NOT use the infamous sun.misc.BASE64Encoder() class, rather we rely on our own, carefully optimized, 100% pure Java code.
data
- The byte array containing 8-bit data to be encoded (if the array
is empty, an empty array will simply be returned)public static String encode(String data)
This method produces a string containing only valid characters from the Base64 alphabet. No white space characters are added, especially including trailing newline characters (which some base 64 encoding routines have been found to include, sometimes intermittently).
We specifically do NOT use the infamous sun.misc.BASE64Encoder() class, rather we rely on our own, carefully optimized, 100% pure Java code.
data
- The byte array containing 8-bit data to be encoded (if the array
is empty, an empty array will simply be returned)public static byte[] sloppyDecode(byte... data)
This method produces a byte array containing 8-bit bytes.
data
- The byte array containing Base64-encoded data to be decoded (if
the array is empty, an empty array will simply be returned)public static byte[] sloppyDecode(String data)
This method produces a byte array containing 8-bit bytes.
data
- The String containing Base64-encoded data to be decoded (if the
string is empty, an empty array will simply be returned)