Returns a codec for encoding and decoding base-64 strings.
This codec serializes strings using a base-64 encoding scheme, commonly used for data encoding in URLs, cryptographic keys, and binary-to-text encoding.
Encoding and decoding a base-64 string.
const codec = getBase64Codec();const bytes = codec.encode('hello+world'); // 0x85e965a3ec28ae57const value = codec.decode(bytes); // "hello+world" Copy
const codec = getBase64Codec();const bytes = codec.encode('hello+world'); // 0x85e965a3ec28ae57const value = codec.decode(bytes); // "hello+world"
This codec does not enforce a size boundary. It will encode and decode all bytes necessary to represent the string.
If you need a fixed-size base-64 codec, consider using fixCodecSize.
const codec = fixCodecSize(getBase64Codec(), 8); Copy
const codec = fixCodecSize(getBase64Codec(), 8);
If you need a size-prefixed base-64 codec, consider using addCodecSizePrefix.
const codec = addCodecSizePrefix(getBase64Codec(), getU32Codec()); Copy
const codec = addCodecSizePrefix(getBase64Codec(), getU32Codec());
Separate getBase64Encoder and getBase64Decoder functions are available.
const bytes = getBase64Encoder().encode('hello+world');const value = getBase64Decoder().decode(bytes); Copy
const bytes = getBase64Encoder().encode('hello+world');const value = getBase64Decoder().decode(bytes);
A VariableSizeCodec<string> for encoding and decoding base-64 strings.
VariableSizeCodec<string>
Returns a codec for encoding and decoding base-64 strings.
This codec serializes strings using a base-64 encoding scheme, commonly used for data encoding in URLs, cryptographic keys, and binary-to-text encoding.
Example
Encoding and decoding a base-64 string.
Remarks
This codec does not enforce a size boundary. It will encode and decode all bytes necessary to represent the string.
If you need a fixed-size base-64 codec, consider using fixCodecSize.
If you need a size-prefixed base-64 codec, consider using addCodecSizePrefix.
Separate getBase64Encoder and getBase64Decoder functions are available.
See