Create a new Bcrypt hash driver instance
Configuration options for the Bcrypt hasher
Check if the value is a valid hash. This method just checks for the formatting of the hash.
bcrypt.isValidHash('hello world') // false
bcrypt.isValidHash('$bcrypt$v=98$r=10$Jtxi46WJ26OQ0khsYLLlnw$knXGfuRFsSjXdj88JydPOnUIglvm1S8')
The value to check
True if the value is a valid Bcrypt hash format
Hash a plain text value
const hash = await bcrypt.make('password')
The plain text value to hash
Promise resolving to the Bcrypt hash
Verify the plain text value against an existing hash
if (await bcrypt.verify(hash, plainText)) {
}
The hashed value to verify against
The plain text value to verify
Promise resolving to true if verification succeeds
Find if the hash value needs a rehash or not. The rehash is required when.
const isValid = await bcrypt.verify(hash, plainText)
// Plain password is valid and hash needs a rehash
if (isValid && await bcrypt.needsReHash(hash)) {
const newHash = await bcrypt.make(plainText)
}
The hashed value to check
True if the hash needs to be rehashed
Hash driver built on top of "bcrypt" hash algorigthm. Under the hood we make use of the "bcrypt" npm package.
The Bcrypt implementation uses the PHC formatting for creating and verifying hashes.