Oslo

Bcrypt

Provides methods for hashing passwords and verifying hashes with bcrypt. By default, the configuration is set to the recommended values.

We recommend using Argon2id or Scrypt if possible.

Implements PasswordHashingAlgorithm.

Constructor

function constructor(options?: { cost?: number }): this;

Parameters

  • options
    • cost (default: 10)

Methods

Example

import { Bcrypt } from "oslo/password";

const bcrypt = new Bcrypt();
const hash = await bcrypt.hash(password);
const validPassword = await bcrypt.verify(hash, password);