This package contains the “base” codecs defined by RFC 4648. These codecs are used to encode binary data into various standardised text representations for portability in environments that are not binary-safe.

Since the text output of each of the primary CharacterToByteCodec codecs (labelled String) in this family are within the range of ASCII characters, they all have a variant ByteToByteCodec codec (labelled Byte) that outputs the ascii encoded characters directly. This is sometimes desireable for efficiency reasons.

Any Byte can be encoded without error by all of the codecs in this family. However DecodeException may be thrown when decoding Characters or Bytes into Bytes, as the valid text format for each codec is strictly defined.

Some of the codecs' text forms append padding characters (typically =) to prevent ambiguity when concatenated. If you're transporting them discretely it is technically safe to remove these padding characters. However, while the decode functions of the codecs implemented here accept padding-less input, it's not uncommon for other libraries to only accept properly padded input. Portability may be affected by removing the padding characters.

To convert some Bytes into a base64 String:

String string = base64StringStandard.encode({0, 1, 2}*.byte);

Now, if you want to decode it back:

List<Byte> bytes = base64StringStandard.decode(string);

Similarly, for a Buffer:

CharacterBuffer chars = base64StringUrl.encodeBuffer({3, 2, 1}*.byte);
ByteBuffer bytes = base64StringUrl.decodeBuffer(chars);

If you only know the name of a base you can get its String form with

CharacterToByteCodec? codec = baseStringByAlias["base32hex"];

and its Byte form with

ByteToByteCodec? codec = baseByteByAlias["base32hex"];
By: Stéphane Épardaud, Alex Szczuczko
Values
base16ByteSource Codeshared base16Byte base16Byte
base16StringSource Codeshared base16String base16String
base32ByteHexSource Codeshared base32ByteHex base32ByteHex
base32ByteStandardSource Codeshared base32ByteStandard base32ByteStandard
base32StringHexSource Codeshared base32StringHex base32StringHex
base32StringStandardSource Codeshared base32StringStandard base32StringStandard
base64ByteStandardSource Codeshared base64ByteStandard base64ByteStandard

The Basic type base64 encoding scheme of RFC 4648.

base64ByteUrlSource Codeshared base64ByteUrl base64ByteUrl

The URL and Filename safe type base64 encoding scheme of RFC 4648.

base64StringStandardSource Codeshared base64StringStandard base64StringStandard

The Basic type base64 encoding scheme of RFC 4648.

base64StringUrlSource Codeshared base64StringUrl base64StringUrl

The URL and Filename safe type base64 encoding scheme of RFC 4648.

baseByteByAliasSource Codeshared Map<String,ByteToByteCodec> baseByteByAlias

A mapping of all supported Byte base variants.

Currently this contains:

  • Base64 Standard
  • Base64 URL Safe
  • Base16
baseStringByAliasSource Codeshared Map<String,CharacterToByteCodec> baseStringByAlias

A mapping of all supported String base variants.

Currently this contains:

  • Base64 Standard
  • Base64 URL Safe
  • Base16
Classes
Base16Source Codeshared abstract sealed Base16<ToMutable,ToImmutable,ToSingle>
given ToMutable satisfies Buffer<ToSingle>
given ToSingle satisfies Object
Base16ByteSource Codeshared abstract Base16Byte
Base16StringSource Codeshared abstract Base16String
Base32Source Codeshared abstract sealed Base32<ToMutable,ToImmutable,ToSingle>
given ToMutable satisfies Buffer<ToSingle>
given ToSingle satisfies Object
Base32ByteSource Codeshared abstract Base32Byte
Base32StringSource Codeshared abstract Base32String
Base64Source Codeshared abstract sealed Base64<ToMutable,ToImmutable,ToSingle>
given ToMutable satisfies Buffer<ToSingle>
given ToSingle satisfies Object
Base64ByteSource Codeshared abstract Base64Byte
Base64StringSource Codeshared abstract Base64String
base16ByteSource Codeshared base16Byte
base16StringSource Codeshared base16String
base32ByteHexSource Codeshared base32ByteHex
base32ByteStandardSource Codeshared base32ByteStandard
base32StringHexSource Codeshared base32StringHex
base32StringStandardSource Codeshared base32StringStandard
base64ByteStandardSource Codeshared base64ByteStandard

The Basic type base64 encoding scheme of RFC 4648.

base64ByteUrlSource Codeshared base64ByteUrl

The URL and Filename safe type base64 encoding scheme of RFC 4648.

base64StringStandardSource Codeshared base64StringStandard

The Basic type base64 encoding scheme of RFC 4648.

base64StringUrlSource Codeshared base64StringUrl

The URL and Filename safe type base64 encoding scheme of RFC 4648.