Hashing & Passwords in Bun

From the Bun cheat sheet ยท Environment & Utilities ยท verified Jul 2026

Hashing & Passwords

Built-in hashing and secure password operations

typescript
// Hash a string
const hash = Bun.hash("hello world");

// Hash a password (argon2id by default)
const hashed = await Bun.password.hash("secret123");
const valid = await Bun.password.verify("secret123", hashed);
๐Ÿ’ก Bun.password.hash uses argon2id by default โ€” bcrypt is also available via the algorithm option
โšก Bun.hash is non-cryptographic but extremely fast โ€” use for cache keys and checksums
๐Ÿ“Œ Use Bun.CryptoHasher for SHA-256/SHA-512 when you need cryptographic guarantees
๐ŸŸข Bun.sleep() is a built-in async sleep โ€” no setTimeout wrapper needed
hashpasswordcryptobcrypt

More Bun tasks

Back to the full Bun cheat sheet