Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bcrypt

Package Overview
Dependencies
Maintainers
5
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcrypt

A bcrypt library for NodeJS.

  • 1.1.0-napi
  • n-api
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.1M
decreased by-40.44%
Maintainers
5
Weekly downloads
 
Created

What is bcrypt?

The bcrypt npm package is a library for hashing and comparing passwords securely in Node.js. It implements the bcrypt password-hashing function, which is designed to build a cryptographic hash of a user's password. Bcrypt is widely used due to its security features and resistance to brute-force attacks.

What are bcrypt's main functionalities?

Hashing Passwords

This feature allows you to securely hash a plaintext password. The 'saltRounds' parameter defines the cost factor for the hashing process, which determines the amount of time required to calculate a single bcrypt hash.

const bcrypt = require('bcrypt');
const saltRounds = 10;
const myPlaintextPassword = 's0/\/\P4$$w0rD';

bcrypt.hash(myPlaintextPassword, saltRounds, function(err, hash) {
  // Store hash in your password DB.
});

Comparing Passwords

This feature is used to compare a plaintext password against a previously hashed one to check if they match. It is commonly used during the login process to validate user credentials.

const bcrypt = require('bcrypt');
const myPlaintextPassword = 's0/\/\P4$$w0rD';
const someOtherPlaintextPassword = 'not_bacon';
const hash = '$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy';

bcrypt.compare(myPlaintextPassword, hash, function(err, result) {
  // result == true
});

bcrypt.compare(someOtherPlaintextPassword, hash, function(err, result) {
  // result == false
});

Other packages similar to bcrypt

Keywords

FAQs

Package last updated on 21 Jan 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc