verify method
Verifies if a password matches a bcrypt hash. Returns Result<bool> - true if password matches, false otherwise.
Implementation
Result<bool> verify(String password, String hash) {
if (password.isEmpty) {
return Result.error('[InvalidArgument] Password is empty');
}
if (hash.isEmpty) {
return Result.error('[InvalidArgument] Hash is empty');
}
try {
final isValid = BCrypt.checkpw(password, hash);
return Result.value(isValid);
} catch (e) {
return Result.error('[Internal] Verification failed: $e');
}
}