fromString static method

K4Sid fromString(
  1. String encoded
)

Implementation

static K4Sid fromString(String encoded) {
  if (!encoded.startsWith(PaserkKey.k4SidPrefix)) {
    throw ArgumentError('Invalid k4.sid format');
  }

  final decoded =
      SafeBase64.decode(encoded.substring(PaserkKey.k4SidPrefix.length));
  if (decoded.length != hashLength) {
    throw ArgumentError('Decoded k4.sid must be exactly $hashLength bytes');
  }
  return K4Sid(Uint8List.fromList(decoded));
}