public final class Base64Codec extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
computeEncodedLength(int inputLength,
boolean urlSafe)
Computes the base64 encoded character length for the specified input byte length.
|
static byte[] |
decode(byte[] value)
Decodes a base64 or base64 URL-safe encoded string represented as byte array using UTF-8 encoding.
|
static byte[] |
decode(String value)
Decodes a base64 or base64 URL-safe encoded string.
|
static char[] |
encodeToChar(byte[] byteArray,
boolean urlSafe)
Encodes a byte array into a base64 encoded character array.
|
static String |
encodeToString(byte[] byteArray,
boolean urlSafe)
Encodes a byte array into a base64 encoded string.
|
static boolean |
isBase64Encoded(byte[] value)
Test to see if the byte array contains a valid Base64 value.
|
static boolean |
isBase64Encoded(String value)
Test to see if the String contains a valid Base64 value.
|
static String |
normalizeEncodedString(String value)
Normalises a base64 encoded string by ensuring any URL-safe
characters are replaced with their regular base64 representation and
any truncated '=' padding is restored.
|
public static boolean isBase64Encoded(String value)
value - The value to testpublic static boolean isBase64Encoded(byte[] value)
value - The value to testpublic static int computeEncodedLength(int inputLength,
boolean urlSafe)
inputLength - The input byte length.urlSafe - true for URL-safe encoding.public static String normalizeEncodedString(String value)
value - The base 64 or base 64 URL-safe encoded string.
Must not be null.public static char[] encodeToChar(byte[] byteArray,
boolean urlSafe)
byteArray - The bytes to convert. If null or length 0
an empty array will be returned.urlSafe - If true to apply URL-safe encoding (padding
still included and not to spec).null.public static String encodeToString(byte[] byteArray, boolean urlSafe)
byteArray - The bytes to convert. If null or length 0
an empty array will be returned.urlSafe - If true to apply URL-safe encoding (padding
still included and not to spec).null.public static byte[] decode(String value)
value - The base 64 or base 64 URL-safe encoded string. May
be empty or null.null or corrupted.public static byte[] decode(byte[] value)
value - The base 64 or base 64 URL-safe encoded byte array. May
be empty or null.null or corrupted.Copyright © 2014–2018. All rights reserved.