encodeBytes static method

String encodeBytes(
  1. List<int> data, [
  2. String? customAlphabet
])

Encode the provided List

Implementation

static String encodeBytes(List<int> data, [String? customAlphabet]) {
  data = data.asImmutableBytes;

  /// Encode the input bytes in Base32.
  String encoded = StringUtils.decode(
      _Base32Utils._b32encode(_Base32Const.alphabet, data));

  /// If a custom alphabet is specified, translate the encoded string to the custom alphabet.
  if (customAlphabet != null) {
    encoded = _Base32Utils.translateAlphabet(
        encoded, _Base32Const.alphabet, customAlphabet);
  }

  /// Return the Base32 encoded string.
  return encoded;
}