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