decode static method

Uint8List decode(
  1. String input
)

Decodes a multibase-encoded string into raw bytes.

The input string must include the multibase prefix character.

Implementation

static Uint8List decode(String input) {
  if (input.isEmpty) {
    throw const FormatException('Empty multibase input');
  }
  final payload = input.substring(1);
  switch (input[0]) {
    case 'f':
      return _hexDecode(payload.toLowerCase());
    case 'F':
      return _hexDecode(payload.toLowerCase());
    case 'b':
      return _base32Decode(payload.toLowerCase());
    case 'B':
      return _base32Decode(payload.toLowerCase());
    case 'm':
      return _base64Decode(payload, urlSafe: false);
    case 'u':
      return _base64Decode(payload, urlSafe: true);
    case 'U':
      return _base64Decode(payload, urlSafe: true);
    case 'z':
      return Uint8List.fromList(mb.multibaseDecode(input));
    default:
      return Uint8List.fromList(mb.multibaseDecode(input));
  }
}