MCPcopy
hub / github.com/dcodeIO/bcrypt.js / compareSync

Function compareSync

index.js:226–234  ·  view source on GitHub ↗
(password, hash)

Source from the content-addressed store, hash-verified

224 * @throws {Error} If an argument is illegal
225 */
226export function compareSync(password, hash) {
227 if (typeof password !== "string" || typeof hash !== "string")
228 throw Error("Illegal arguments: " + typeof password + ", " + typeof hash);
229 if (hash.length !== 60) return false;
230 return safeStringCompare(
231 hashSync(password, hash.substring(0, hash.length - 31)),
232 hash,
233 );
234}
235
236/**
237 * Asynchronously tests a password against a hash.

Callers

nothing calls this directly

Calls 2

safeStringCompareFunction · 0.85
hashSyncFunction · 0.85

Tested by

no test coverage detected