encode static method
Encode the provided string into a Base32 encoded string. Optionally, you can specify a custom alphabet for encoding.
Implementation
static String encode(String data, [String? customAlphabet]) {
/// Convert the input string to UTF-8 encoded bytes and then encode it in Base32.
String encoded = StringUtils.decode(_Base32Utils._b32encode(
_Base32Const.alphabet, StringUtils.encode(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;
}