New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

bcrypt-edge

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcrypt-edge

Bcrypt implementation specifically for web workers

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
2.3K
39.28%
Maintainers
1
Weekly downloads
 
Created
Source

[!CAUTION] This library is no longer maintained, please consider switching to bcrypt-ts, which is better in every way.

bcrypt-edge

npm

ESM Edge/worker conversion for bcrypt.js.

Description

This is a re-implementation of Bcrypt specifically for web workers, in particular Cloudflare. The following differences can be observed from the source library:

  • The package is now an ESM, so it can easily be bundled
  • All async methods have been removed. These don't work in a Web Worker environment, so they were removed.
    • Perhaps there is some method of re-introducing them, but the originals relied upon process.nextTick
    • Additionally in a worker scenario, each request is theoretically isolated anyway so async isn't as impactful
  • Unit tests were preserved/translated as best as they could be
    • Tests are run against the Cloudflare crypto compatibility layer via Miniflare
    • No discrepencies between the original implementation and this one have been observed

Care was taken to disturb as little as possible with the initial implementation.

Usage

Usage is similar to the original library, except it's an ESM worker module now and has no async methods.

import {
  genSaltSync,
  hashSync,
  compareSync,
  getRounds,
  getSaltSync,
} from 'bcrypt-edge';

// Hashing
const salt = bcrypt.genSaltSync(10);
const hash = bcrypt.hashSync('B4c0//', salt);

// Create Salt+Hash in one line
const hash = bcrypt.hashSync('bacon', 8);

// Comparing
bcrypt.compareSync('B4c0//', hash); // true
bcrypt.compareSync('not_bacon', hash); // false

Benchmarks

Running bcrypt-edge in Miniflare against the original bcrypt package, the benchmarks are as follows. It is very likely that platform specific inhancements could be made to improve performace of bcrypt-edge.

LibraryRoundsHash Time
bcryptjs820ms
bcrypt-edge835ms
bcryptjs940ms
bcrypt-edge972ms
bcryptjs1081ms
bcrypt-edge10143ms
bcryptjs11161ms
bcrypt-edge11278ms
bcryptjs12326ms
bcrypt-edge12564ms
bcryptjs13653ms
bcrypt-edge131138ms
bcryptjs141316ms
bcrypt-edge142266ms
bcryptjs152646ms
bcrypt-edge154498ms

Keywords

encryption

FAQs

Package last updated on 03 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts