public final class Base64 extends Object
Sample use case as below:
String credentials = Strings.concat(user, ':', password); String basicAuthorization = "Basic " + Base64.encode(credentials);
Modifier and Type | Field and Description |
---|---|
private static byte[] |
CHARS_2_NIBLES
Mapping table from Base64 characters to 6-bit nibbles.
|
private static char[] |
NIBLES_2_CHARS
Mapping table from 6-bit nibbles to Base64 characters.
|
Modifier | Constructor and Description |
---|---|
private |
Base64()
Prevent default constructor synthesis.
|
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(String base64)
Decodes a byte array from a Base64 formated string.
|
static String |
encode(byte[] bytes)
Encodes a byte array into Base64 format.
|
static String |
encode(String string)
Encode string value into Base64 format.
|
private static final char[] NIBLES_2_CHARS
private static final byte[] CHARS_2_NIBLES
public static String encode(String string)
string
- string to encode.string
value encoded Base64.public static String encode(byte[] bytes)
bytes
- an array containing the data bytes to be encoded.public static byte[] decode(String base64)
base64
- a character array containing the Base64 encoded data.IllegalArgumentException
- if the input is not valid Base64 encoded data.Copyright © 2018. All rights reserved.