Socket
Socket
Sign inDemoInstall

pbkdf2

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pbkdf2

Hash password and compare using PBKDF2, pbkdf2-sha1, pbkdf2-sha256, pbkdf2-sha512.


Version published
Maintainers
1
Install size
7.19 kB
Created

Package description

What is pbkdf2?

The pbkdf2 npm package is a library that implements the password-based key derivation function 2 (PBKDF2). It is used to securely derive a cryptographic key from a password. This package is a pure JavaScript implementation and can be used in Node.js applications.

What are pbkdf2's main functionalities?

Deriving a key from a password

This code sample demonstrates how to use the pbkdf2 package to derive a cryptographic key from a password. It uses a random salt, a specified number of iterations, key length, and digest algorithm.

const crypto = require('crypto');
const pbkdf2 = require('pbkdf2');

const password = 'secret';
const salt = crypto.randomBytes(16).toString('hex');
const iterations = 100000;
const keylen = 64;
const digest = 'sha512';

pbkdf2.pbkdf2(password, salt, iterations, keylen, digest, (err, derivedKey) => {
  if (err) throw err;
  console.log(derivedKey.toString('hex')); // '3745e48...aa39b34'
});

Other packages similar to pbkdf2

Readme

Source

pbkdf2 Build Status

Information

Package
DescriptionHash password and compare with PBKDF2, use sha1, sha256, sha512, etc.
Node Version>= 0.11.11

Install

npm install pbkdf2

Usage

var pbkdf2 = require('pbkdf2');
var p = 'password';
var s = pbkdf2.generateSaltSync(32);
var pwd = pbkdf2.hashSync(p, s, 1, 20, 'sha256');
var bool = pbkdf2.compareSync(pwd, p, s, 1, 20, 'sha256');

API

  • hash(password, salt, iterations, keylen, algorithm, callback(password_hash))
  • hashSync(password, salt, iterations, keylen, algorithm), return password_hash
  • generateSalt(callback(salt), saltlen)
  • generateSaltSync(saltlen), return salt
  • compare(password_hash, password, salt, iterations, keylen, algorithm, callback(bool))
  • compareSync(password_hash, password, salt, iterations, keylen, algorithm), return bool

Bitdeli Badge

Keywords

FAQs

Last updated on 18 Apr 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc