HashedPassword.fromCombined constructor
HashedPassword.fromCombined(
- String combined
Parses a combined string produced by PasswordHasher.hash.
Use this to reconstruct a HashedPassword from a value you read back from Firestore before passing it to PasswordHasher.verify.
Implementation
factory HashedPassword.fromCombined(String combined) {
final parts = combined.split(':');
if (parts.length != 3) {
throw ArgumentError(
'Invalid HashedPassword format. '
'Expected "iterations:saltBase64:hashBase64", got: "$combined"',
);
}
final iterations = int.tryParse(parts[0]);
if (iterations == null) {
throw ArgumentError(
'Iteration count is not a valid integer: ${parts[0]}');
}
return HashedPassword.create(
iterations: iterations,
salt: parts[1],
hash: parts[2],
combined: combined,
);
}