Class BaseEncoding

A binary encoding scheme for reversibly translating between byte sequences and printable ASCII
strings. This class includes several constants for encoding schemes specified by RFC 4648. For example, the expression:

BaseEncoding.base32().encode("foo".getBytes(Charsets.US_ASCII))

returns the string "MZXW6===", and

byte[] decoded = BaseEncoding.base32().decode("MZXW6===");

...returns the ASCII bytes of the string "foo".

By default, BaseEncoding's behavior is relatively strict and in accordance with
RFC 4648. Decoding rejects characters in the wrong case, though padding is optional.
To modify encoding and decoding behavior, use configuration methods to obtain a new encoding
with modified behavior:

BaseEncoding.base16().lowerCase().decode("deadbeef");

Warning: BaseEncoding instances are immutable. Invoking a configuration method has no effect
on the receiving instance; you must store and use the new encoding instance it returns, instead.

// Do NOT do this
BaseEncoding hex = BaseEncoding.base16();
hex.lowerCase(); // does nothing!
return hex.decode("deadbeef"); // throws an IllegalArgumentException

It is guaranteed that encoding.decode(encoding.encode(x)) is always equal to
x, but the reverse does not necessarily hold.

The "base64url" encoding specified by RFC 4648 section 5, Base 64 Encoding
with URL and Filename Safe Alphabet, also sometimes referred to as the "web safe Base64."
(This is the same as the base 64 encoding with URL and filename safe alphabet from RFC 3548.)

withSeparator

Returns an encoding that behaves equivalently to this encoding, but adds a separator string
after every n characters. Any occurrences of any characters that occur in the separator
are skipped over in decoding.

base64Url

The "base64url" encoding specified by RFC 4648 section 5, Base 64 Encoding
with URL and Filename Safe Alphabet, also sometimes referred to as the "web safe Base64."
(This is the same as the base 64 encoding with URL and filename safe alphabet from RFC 3548.)