base32Decode static method

List<int> base32Decode(
  1. String input
)

Implementation

static List<int> base32Decode(String input) {
  final String clean = input.toUpperCase().replaceAll("=", "").replaceAll(RegExp(r"\s"), "");
  final List<int> out = <int>[];
  int value = 0;
  int bits = 0;
  for (final int rune in clean.runes) {
    final int index = _base32Alphabet.indexOf(String.fromCharCode(rune));
    if (index < 0) throw const FormatException("Invalid Base32 character.");
    value = (value << 5) | index;
    bits += 5;
    if (bits >= 8) {
      bits -= 8;
      out.add((value >> bits) & 0xFF);
    }
  }
  return out;
}