{ } qjs-modules

password

Source: lib/password.js (pure JS) — default export: { hash, hashSync, verify, verifySync }

Bun.password-compatible password hashing/verification (https://bun.com/docs/api/hashing, https://bun.com/guides/util/hash-a-password), backed by the native bcrypt module (libbcrypt).

Bun supports both bcrypt and Argon2 (its default). This engine only has a bcrypt binding - no Argon2 - so options.algorithm here only ever accepts "bcrypt" (the default); anything else throws instead of silently hashing with an unavailable algorithm. verify()/verifySync() don't take an algorithm option, same as Bun's: bcrypt's $2b$<cost>$... hash format is self-describing.

Exports

ExportArgsKindDescription
hash(password, options?)1-2async functionHashes password. options: { algorithm: "bcrypt", cost } (cost 4-31, default 12).
hashSync(password, options?)1-2functionSynchronous hash().
verify(password, hash)2async functionWhether password matches hash.
verifySync(password, hash)2functionSynchronous verify().
(default)—object{ hash, hashSync, verify, verifySync }

Example

import { hash, verify } from 'password';

const h = await hash('super-secure-pa$$word');
await verify('super-secure-pa$$word', h); // true

Export list

Generated by utilities/doc-api.js from the password dump of utilities/api-surface.sh: 9 members. Edit the text above this block, not the block.

Functions: hash(), hashSync(), verify(), verifySync()

default

object

  • static methods: hash(), hashSync(), verify(), verifySync()