decode static method
Decode the provided Base32 string into a List of bytes. Optionally, you can specify a custom alphabet for decoding.
Implementation
static List<int> decode(String data, [String? customAlphabet]) {
try {
/// Add padding characters to the input data as needed.
data = _Base32Utils.addPadding(data);
/// If a custom alphabet is specified, translate the input data to the standard Base32 alphabet.
if (customAlphabet != null) {
data = _Base32Utils.translateAlphabet(
data,
customAlphabet,
_Base32Const.alphabet,
);
}
/// Decode the Base32 string and obtain the decoded bytes.
return _Base32Utils._b32decode(_Base32Const.alphabet, data);
} catch (_) {
/// Handle exceptions by throwing an error for invalid Base32 strings.
throw ArgumentException.invalidOperationArguments(
"decode",
name: "data",
reason: 'Invalid Base32 string',
);
}
}