verify method

Result<bool> verify(
  1. String password,
  2. String hash
)

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');
  }
}