codecs library

Implementations of fast and error resilient codecs

Classes

AlphabetDecoder
A ByteDecoder that maps each input character code to its word value through an alphabet lookup table before regrouping the bits.
AlphabetEncoder
A ByteEncoder that maps each output word to a character code through an alphabet lookup table, optionally appending a padding character.
Base16Codec
Encodes and decodes 8-bit byte sequences as Base-16 (hexadecimal) text.
Base2Codec
Encodes and decodes 8-bit byte sequences as Base-2 (binary) text.
Base32Codec
Encodes and decodes 8-bit byte sequences as Base-32 text.
Base32Decoder
A specialized AlphabetDecoder for Base-32.
Base32Encoder
A specialized single-pass AlphabetEncoder for Base-32.
Base64Codec
Encodes and decodes 8-bit byte sequences as Base-64 text.
Base64Decoder
A specialized AlphabetDecoder for Base-64.
Base64Encoder
A specialized single-pass AlphabetEncoder for Base-64.
Base8Codec
Encodes and decodes 8-bit byte sequences as Base-8 (octal) text.
BigIntCodec
Encodes an 8-bit byte sequence into a non-negative BigInt and decodes it back into bytes.
BitConverter
Base class for bit-wise encoder and decoder implementation
BitDecoder
A generic decoder that repacks a bit stream into fixed-width words.
BitEncoder
A generic encoder that repacks a bit stream into fixed-width words.
ByteCollector
A container for digest bytes produced by a hash or encoding function.
ByteDecoder
A BitDecoder whose output words are 8-bit bytes.
ByteEncoder
A BitEncoder whose input words are 8-bit bytes.
CryptData
A parsed PHC / Modular Crypt Format string: an algorithm id with an optional version, params, salt, and hash.
CryptDataBuilder
Convenient builder for CryptData.
CryptDecoder
The decoder used by the CryptFormat codec
CryptEncoder
The encoder used by the CryptFormat codec
CryptFormat
Provides encoding and decoding of PHC string format data.
IterableCodec
Base class for encoding from and to 8-bit integer sequence
UTF8Codec
Encodes UTF-16 code units into a UTF-8 octet sequence and decodes UTF-8 octets back into code points.
UTF8Decoder
Decodes a UTF-8 octet sequence back into a sequence of Unicode code points.
UTF8Encoder
Encodes a sequence of Unicode code points into a UTF-8 octet sequence.

Constants

crypt → const CryptFormat
An instance of CryptFormat for encoding and decoding hash algorithm output with PHC string format

Functions

constantTimeEquals(List<int> a, List<int> b) bool
Compares a and b for equality in constant time.
fromBase32(String input, {Base32Codec? codec, bool padding = true}) Uint8List
Converts 5-bit Base-32 character sequence to 8-bit integer sequence.
fromBase64(String input, {Base64Codec? codec, bool padding = true}) Uint8List
Converts 6-bit Base-64 character sequence to 8-bit integer sequence.
fromBigInt(BigInt input, {BigIntCodec? codec, bool msbFirst = false}) Uint8List
Converts a BigInt to 8-bit integer sequence.
fromBinary(String input, {Base2Codec codec = Base2Codec.standard}) Uint8List
Converts 2-bit Base-2 character sequence to 8-bit integer sequence.
fromCrypt(String input) CryptData
Decodes a PHC / Modular Crypt Format string into CryptData.
fromHex(String input, {Base16Codec? codec}) Uint8List
Converts 4-bit Base-16 character sequence to 8-bit integer sequence.
fromOctal(String input, {Base8Codec codec = Base8Codec.standard}) Uint8List
Converts 3-bit Base-8 character sequence to 8-bit integer sequence.
fromUtf8(List<int> input, {UTF8Codec codec = UTF8Codec.standard}) String
Converts 8-bit UTF-8 octet sequence to UTF-8 character code points.
toBase32(List<int> input, {Base32Codec? codec, bool lower = false, bool padding = true}) String
Converts 8-bit integer sequence to 5-bit Base-32 character sequence.
toBase32Bytes(List<int> input, {Base32Codec? codec, bool lower = false, bool padding = true}) Uint8List
Converts 8-bit integer sequence to Base-32 and returns the ASCII bytes.
toBase64(List<int> input, {Base64Codec? codec, bool url = false, bool padding = true}) String
Converts 8-bit integer sequence to 6-bit Base-64 character sequence.
toBase64Bytes(List<int> input, {Base64Codec? codec, bool url = false, bool padding = true}) Uint8List
Converts 8-bit integer sequence to Base-64 and returns the ASCII bytes.
toBigInt(Iterable<int> input, {BigIntCodec? codec, bool msbFirst = false}) BigInt
Converts 8-bit integer sequence to BigInt.
toBinary(List<int> input, {Base2Codec codec = Base2Codec.standard}) String
Converts 8-bit integer sequence to 2-bit Base-2 character sequence.
toBinaryBytes(List<int> input, {Base2Codec codec = Base2Codec.standard}) Uint8List
Converts 8-bit integer sequence to Base-2 and returns the ASCII bytes.
toCrypt(CryptData input) String
Encodes input into a PHC / Modular Crypt Format string.
toHex(List<int> input, {Base16Codec? codec, bool upper = false}) String
Converts 8-bit integer sequence to 4-bit Base-16 character sequence.
toHexBytes(List<int> input, {Base16Codec? codec, bool upper = false}) Uint8List
Converts 8-bit integer sequence to Base-16 and returns the ASCII bytes.
toOctal(List<int> input, {Base8Codec codec = Base8Codec.standard}) String
Converts 8-bit integer sequence to 3-bit Base-8 character sequence.
toOctalBytes(List<int> input, {Base8Codec codec = Base8Codec.standard}) Uint8List
Converts 8-bit integer sequence to Base-8 and returns the ASCII bytes.
toUtf8(String input, {UTF8Codec codec = UTF8Codec.standard}) Uint8List
Converts UTF-8 character code points to 8-bit UTF-8 octet sequence.
tryFromBase32(String input, {Base32Codec? codec, bool padding = true}) Uint8List?
Converts a Base-32 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.
tryFromBase64(String input, {Base64Codec? codec, bool padding = true}) Uint8List?
Converts a Base-64 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.
tryFromBigInt(BigInt input, {BigIntCodec? codec, bool msbFirst = false}) Uint8List?
Converts a non-negative BigInt to an 8-bit integer sequence, returning null instead of throwing when the input is negative.
tryFromBinary(String input, {Base2Codec codec = Base2Codec.standard}) Uint8List?
Converts a Base-2 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.
tryFromHex(String input, {Base16Codec? codec}) Uint8List?
Converts a Base-16 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.
tryFromOctal(String input, {Base8Codec codec = Base8Codec.standard}) Uint8List?
Converts a Base-8 string to an 8-bit integer sequence, returning null instead of throwing when the input is not valid.
tryFromUtf8(List<int> input, {UTF8Codec codec = UTF8Codec.standard}) String?
Converts a UTF-8 octet sequence to code points, returning null instead of throwing when the input is not a valid UTF-8 octet sequence.

Typedefs

BigIntDecoder = Converter<BigInt, Uint8List>
A converter that decodes a BigInt back into an 8-bit integer sequence.
BigIntEncoder = Converter<Iterable<int>, BigInt>
A converter that encodes an 8-bit integer sequence into a BigInt.