Instance Method
verify(_:created:)
Verifies an existing BCrypt hash matches the supplied plaintext value. Verification works by parsing the salt and version from the existing digest and using that information to hash the plaintext data. If hash digests match, this method returns
true.func verify(_ plaintext: String, created hash: String) throws -> Bool
Parameters
plaintextPlaintext data to digest and verify.
hashExisting BCrypt hash to parse version, salt, and existing digest from.
Return Value
true if the hash was created from the supplied plaintext data.
Discussion
let hash = try BCrypt.hash("vapor", cost: 4)
try BCrypt.verify("vapor", created: hash) // true
try BCrypt.verify("foo", created: hash) // false
Throws
CryptoError if hashing fails or if data conversion fails.