public class Base64
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
ALPHABET
The 64 valid Base64 encoding characters.
|
static byte[] |
WEBSAFE_ALPHABET
The 64 valid web safe Base64 encoding characters.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(byte[] source)
Decodes Base64 content in byte array format and returns
the decoded byte array.
|
static byte[] |
decode(byte[] source,
int off,
int len)
Decodes Base64 content in byte array format and returns
the decoded byte array.
|
static byte[] |
decode(java.lang.String source)
Decodes data from Base64 notation.
|
static java.lang.String |
encode(byte[] source)
Encodes a byte array into Base64 notation.
|
static java.lang.String |
encode(byte[] source,
int off,
int len,
byte[] alphabet,
boolean doPadding)
Encodes a byte array into Base64 notation.
|
static byte[] |
encode(byte[] source,
int off,
int len,
byte[] alphabet,
int maxLineLength)
Encodes a byte array into Base64 notation.
|
static java.lang.String |
encodeWebSafe(byte[] source,
boolean doPadding)
Encodes a byte array into web safe Base64 notation.
|
public static final byte[] ALPHABET
public static final byte[] WEBSAFE_ALPHABET
public static java.lang.String encode(byte[] source)
encodeBytes(source, 0, source.length)
source
- the binary data to encodepublic static java.lang.String encodeWebSafe(byte[] source, boolean doPadding)
source
- the binary data to encodedoPadding
- If true
, pad the result with '=' chars
if it does not fall on 3 byte boundaries.public static java.lang.String encode(byte[] source, int off, int len, byte[] alphabet, boolean doPadding)
source
- the binary data to encodeoff
- offset in array where conversion should beginlen
- length of data to convertalphabet
- the encoding alphabetdoPadding
- If true
, pad the result with '=' chars
if it does not fall on 3 byte boundaries.public static byte[] encode(byte[] source, int off, int len, byte[] alphabet, int maxLineLength)
source
- the data to convertoff
- offset in array where conversion should beginlen
- length of data to convertalphabet
- the encoding alphabetmaxLineLength
- the maximum length of each line of outputpublic static byte[] decode(java.lang.String source) throws Base64DecoderException
source
- the Base64-encoded String to decodeBase64DecoderException
- if the source does not
contain valid Base64-encoded datapublic static byte[] decode(byte[] source) throws Base64DecoderException
source
- the Base64-encoded data to decodeBase64DecoderException
- if the source does not
contain valid Base64-encoded datapublic static byte[] decode(byte[] source, int off, int len) throws Base64DecoderException
source
- the Base64-encoded data to decodeoff
- the offset into source
to begin decodinglen
- the number of characters to decodeBase64DecoderException
- if the source does not
contain valid Base64-encoded data