toBase32Bytes function

Uint8List toBase32Bytes(
  1. List<int> input, {
  2. Base32Codec? codec,
  3. bool lower = false,
  4. bool padding = true,
})

Converts 8-bit integer sequence to Base-32 and returns the ASCII bytes.

This is the same as toBase32 but returns the encoded characters as a Uint8List of ASCII codes, skipping the intermediate String.

Parameters:

  • input is a sequence of 8-bit integers
  • If lower is true, the Base32Codec.lowercase alphabet is used.
  • If padding is true, the output will have padding characters.
  • codec is the Base32Codec to use. It is derived from the other parameters if not provided.

Implementation

Uint8List toBase32Bytes(
  List<int> input, {
  Base32Codec? codec,
  bool lower = false,
  bool padding = true,
}) {
  codec ??= _codecFromParameters(
    lower: lower,
    padding: padding,
  );
  Uint8List out = codec.encoder.convert(input);
  if (!padding && _codecsWithPadding.contains(codec)) {
    out = Uint8List.fromList(
      out.takeWhile((x) => x != codec!.encoder.padding).toList(),
    );
  }
  return out;
}