public class Base64 extends Object
Encodes and decodes to and from Base64 and URL-safe Base64 encodings. URL-safe Base64 encoding being defined here as standard Base64 encoding with the following modifications:
Based on version 2.1 of the Base64 class developed by Robert Harder (public domain). Please visit http://iharder.net/base64 periodically to check for updates or to contribute improvements.
| Modifier and Type | Class and Description |
|---|---|
static class |
Base64.EncodingOption |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decode(byte[] source,
int off,
int len,
Base64.EncodingOption optionThatWasUsed)
Very low-level access to decoding ASCII characters in
the form of a byte array.
|
static byte[] |
decode(String s)
Decodes data from Base64 notation
|
static byte[] |
decode(String s,
Base64.EncodingOption optionThatWasUsed)
Decodes data from Base64 notation
|
static String |
encodeBytes(byte[] source)
Encodes a byte array into Base64 notation using the standard Base64 encoding.
|
static String |
encodeBytes(byte[] source,
Base64.EncodingOption option)
Encodes a byte array into Base64 notation.
|
static String |
encodeBytes(byte[] source,
int off,
int len,
Base64.EncodingOption option)
Encodes a byte array into Base64 notation.
|
void |
initAlphabets(boolean useURLSafeEncoding)
Determine which ALPHABET to use.
|
public void initAlphabets(boolean useURLSafeEncoding)
public static String encodeBytes(byte[] source)
source - The data to convertpublic static String encodeBytes(byte[] source, Base64.EncodingOption option)
source - The data to convertoption - Encoding optionpublic static String encodeBytes(byte[] source, int off, int len, Base64.EncodingOption option)
source - The data to convertoff - Offset in array where conversion should beginlen - Length of data to convertoption - Encoding optionpublic static byte[] decode(byte[] source,
int off,
int len,
Base64.EncodingOption optionThatWasUsed)
source - The Base64 encoded dataoff - The offset of where to begin decodinglen - The length of characters to decodeoptionThatWasUsed - EncodingOption used during the encodingpublic static byte[] decode(String s, Base64.EncodingOption optionThatWasUsed)
s - the string to decodeurlSafeEncodingWasUsed - true if the URL-safe was used to encode the data to be decodedoptionThatWasUsed - EncodingOption used during the encodingpublic static byte[] decode(String s)
s - the string to decodeCopyright © 2025 JBoss by Red Hat. All Rights Reserved.