EncryptedPayload.fromCombined constructor

EncryptedPayload.fromCombined(
  1. String combined
)

Parses a combined string produced by CryptoKit.encrypt.

Use this to reconstruct an EncryptedPayload from a value you read back from Firestore before passing it to CryptoKit.decrypt.

Implementation

factory EncryptedPayload.fromCombined(String combined) {
  final parts = combined.split(':');
  if (parts.length != 2) {
    throw ArgumentError(
      'Invalid EncryptedPayload format. '
      'Expected "ivBase64:ciphertextBase64", got: "$combined"',
    );
  }
  return EncryptedPayload.create(
    iv: parts[0],
    cipherText: parts[1],
    combined: combined,
  );
}