|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.unboundid.util.Base32
@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class Base32
This class provides methods for encoding and decoding data in base32 as
defined in RFC 4648. It
provides a somewhat compact way of representing binary data using only
printable characters (a subset of ASCII letters and numeric digits selected
to avoid ambiguity, like confusion between the number 1 and the uppercase
letter I, and between the number 0 and the uppercase letter O). It uses a
five-bit encoding mechanism in which every five bytes of raw data is
converted into eight bytes of base32-encoded data.
// Base32-encode some raw data:
String base32String = Base32.encode(rawDataBytes);
// Decode a base32 string back to raw data:
byte[] decodedRawDataBytes;
try
{
decodedRawDataBytes = Base32.decode(base32String);
}
catch (ParseException pe)
{
// The string did not represent a valid base32 encoding.
decodedRawDataBytes = null;
}
| Method Summary | |
|---|---|
static byte[] |
decode(java.lang.String data)
Decodes the contents of the provided base32-encoded string. |
static java.lang.String |
decodeToString(java.lang.String data)
Decodes the contents of the provided base32-encoded string to a string containing the raw data using the UTF-8 encoding. |
static java.lang.String |
encode(byte[] data)
Encodes the provided data in base32 format. |
static void |
encode(byte[] data,
ByteStringBuffer buffer)
Appends a base32-encoded representation of the provided data to the given buffer. |
static void |
encode(byte[] data,
int off,
int length,
ByteStringBuffer buffer)
Appends a base32-encoded representation of the provided data to the given buffer. |
static void |
encode(byte[] data,
int off,
int length,
java.lang.StringBuilder buffer)
Appends a base32-encoded representation of the provided data to the given buffer. |
static void |
encode(byte[] data,
java.lang.StringBuilder buffer)
Appends a base32-encoded representation of the provided data to the given buffer. |
static java.lang.String |
encode(java.lang.String data)
Encodes the UTF-8 representation of the provided string in base32 format. |
static void |
encode(java.lang.String data,
ByteStringBuffer buffer)
Appends a base32-encoded version of the contents of the provided buffer (using a UTF-8 representation) to the given buffer. |
static void |
encode(java.lang.String data,
java.lang.StringBuilder buffer)
Appends a base32-encoded version of the contents of the provided buffer (using a UTF-8 representation) to the given buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.String encode(java.lang.String data)
data - The raw data to be encoded. It must not be null.
public static java.lang.String encode(byte[] data)
data - The raw data to be encoded. It must not be null.
public static void encode(java.lang.String data,
java.lang.StringBuilder buffer)
data - The raw data to be encoded. It must not be null.buffer - The buffer to which the base32-encoded data is to be
written.
public static void encode(java.lang.String data,
ByteStringBuffer buffer)
data - The raw data to be encoded. It must not be null.buffer - The buffer to which the base32-encoded data is to be
written.
public static void encode(byte[] data,
java.lang.StringBuilder buffer)
data - The raw data to be encoded. It must not be null.buffer - The buffer to which the base32-encoded data is to be
written.
public static void encode(byte[] data,
int off,
int length,
java.lang.StringBuilder buffer)
data - The array containing the raw data to be encoded. It must
not be null.off - The offset in the array at which the data to encode begins.length - The number of bytes to be encoded.buffer - The buffer to which the base32-encoded data is to be
written.
public static void encode(byte[] data,
ByteStringBuffer buffer)
data - The raw data to be encoded. It must not be null.buffer - The buffer to which the base32-encoded data is to be
written.
public static void encode(byte[] data,
int off,
int length,
ByteStringBuffer buffer)
data - The raw data to be encoded. It must not be null.off - The offset in the array at which the data to encode begins.length - The number of bytes to be encoded.buffer - The buffer to which the base32-encoded data is to be
written.
public static byte[] decode(java.lang.String data)
throws java.text.ParseException
data - The base32-encoded string to decode. It must not be
null.
java.text.ParseException - If the contents of the provided string cannot be
parsed as base32-encoded data.
public static java.lang.String decodeToString(java.lang.String data)
throws java.text.ParseException
data - The base32-encoded string to decode. It must not be
null.
java.text.ParseException - If the contents of the provided string cannot be
parsed as base32-encoded data using the UTF-8
encoding.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||