fromString static method

K4Pid fromString(
  1. String encoded
)

Implementation

static K4Pid fromString(String encoded) {
  if (!encoded.startsWith(PaserkKey.k4PidPrefix)) {
    throw ArgumentError('Invalid k4.pid format');
  }

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