check method

Future<bool> check(
  1. String plain,
  2. String hashed
)

Verifies plain against hashed; the driver is detected from the hash prefix. Unknown or malformed hashes never match.

Implementation

Future<bool> check(String plain, String hashed) {
  final detected = info(hashed).driver;
  if (detected == null) {
    return Future<bool>.value(false);
  }
  if (config.verify &&
      detected != config.driver &&
      !strongDrivers.contains(detected)) {
    throw HashException(
      'This password does not use the ${config.driver.name} algorithm. '
      'Set HASH_VERIFY=false to accept ${detected.name} hashes.',
    );
  }
  return Isolate.run(() => _check(plain, hashed, detected));
}