npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bcrypt-wasm-inline

v1.0.3

Published

bcrypt-wasm-inline is a WebAssembly (WASM) binding for the popular bcrypt hashing algorithm, designed to be used directly in JavaScript applications. This package provides both synchronous and asynchronous methods for hashing passwords and verifying passw

Readme

bcrypt-wasm-inline

bcrypt-wasm-inline is a WebAssembly (WASM) binding for the popular bcrypt hashing algorithm, designed to be used directly in JavaScript applications. This package provides both synchronous and asynchronous methods for hashing passwords and verifying password hashes.

Features

  • Sync and Async Methods: Both synchronous and asynchronous methods to hash passwords and compare them with hashed values.
  • Fast and Secure: Utilizes the bcrypt algorithm, which is well-known for its strong security and resistance to brute-force attacks.
  • WASM-based: By compiling to WebAssembly, it can be used efficiently in web browsers and Node.js environments.
  • Optimized Build with Rollup: The package uses Rollup for bundling, allowing for efficient and optimized JavaScript output.
  • Inline Base64-encoded WASM: The WASM module is bundled as an inline base64-encoded JavaScript string to increase compatibility with different environments, especially where file system access might be limited.
  • TypeScript Support: The package is written in TypeScript and includes type definitions for easy integration with TypeScript projects.
  • Lightweight: The package is lightweight and has minimal dependencies, making it easy to integrate into existing projects.
  • Performance: Processing speed is about 24-26% worse than original bcrypt using node-gyp but about 5-6% better than bcryptjs library using pure js

Installation

To install the package, run:

  npm install bcrypt-wasm-inline

This package is built using WebAssembly and exposes hash and compare functions, making it usable in both Node.js and browser environments.

Usage

Once installed, you can use the functions directly in your JavaScript code.

Importing

In a modern JavaScript or TypeScript environment, import the functions like so:

import bcrypt from 'bcrypt-wasm-inline';

const { hash, hashSync, compare, compareSync } = bcrypt;

Synchronous Hashing (Sync)

To hash a password synchronously, use the hashSync function. This is the fastest option but will block the main thread, so it is recommended to use it only for non-critical operations or small datasets.

const password = 'mySuperSecretPassword';
const saltRounds = 10;

try {
const hashedPassword = bcrypt.hashSync(password, saltRounds);
console.log("Hashed password:", hashedPassword);
} catch (error) {
console.error("Error hashing password:", error);
}

Asynchronous Hashing (Async)

For asynchronous operations, use the hash function. This will return a Promise, allowing you to handle it asynchronously.

const password = 'mySuperSecretPassword';
const saltRounds = 10;

bcrypt.hash(password, saltRounds)
.then(hashedPassword => {
console.log("Hashed password:", hashedPassword);
})
.catch(error => {
console.error("Error hashing password:", error);
});

Synchronous Password Comparison (Sync)

To compare a plaintext password with a hashed password synchronously, use the compareSync function.

const password = 'mySuperSecretPassword';
const hashedPassword = '$2a$10$U2f2A4pJK6vwp7gRjBqFzuM0Iz6dHzvvwfi61QWQW9Fe5CevahwSi';

const isMatch = bcrypt.compareSync(password, hashedPassword);
console.log("Password match:", isMatch); // true or false

Asynchronous Password Comparison (Async)

For asynchronous password comparison, use the compare function. It returns a Promise that resolves to true or false depending on whether the password matches the hash.

const password = 'mySuperSecretPassword';
const hashedPassword = '$2a$10$U2f2A4pJK6vwp7gRjBqFzuM0Iz6dHzvvwfi61QWQW9Fe5CevahwSi';

bcrypt.compare(password, hashedPassword)
.then(isMatch => {
console.log("Password match:", isMatch); // true or false
})
.catch(error => {
console.error("Error comparing password:", error);
});

API

bcrypt.hashSync(data: string, saltOrRounds: number | undefined): string

  • Parameters:
    • data: The plaintext password to be hashed.
    • saltOrRounds: Optional. The number of salt rounds to use. If omitted, it defaults to 10.
  • Returns: The hashed password as a string.

bcrypt.compareSync(data: string, encrypted: string): boolean

  • Parameters:
    • data: The plaintext password to check.
    • encrypted: The hashed password to compare against.
  • Returns: true if the password matches the hash, otherwise false.

bcrypt.hash(data: string, saltOrRounds: number | undefined): Promise<string>

  • Parameters:
    • data: The plaintext password to be hashed.
    • saltOrRounds: Optional. The number of salt rounds to use. If omitted, it defaults to 10.
  • Returns: A Promise that resolves to the hashed password as a string.

bcrypt.compare(data: string, encrypted: string): Promise<boolean>

  • Parameters:
    • data: The plaintext password to check.
    • encrypted: The hashed password to compare against.
  • Returns: A Promise that resolves to true if the password matches the hash, otherwise false.

WebAssembly

This package is built using WebAssembly, providing a fast and secure way to perform password hashing directly in the browser or Node.js.

Browser Support

This package is designed to be used in modern browsers that support WebAssembly. If you are using older browsers that do not support WebAssembly, you may need to polyfill or use a different hashing library.

Node.js Support

This package can also be used in Node.js, which supports WebAssembly natively from version 12.x and above.