Skip to content

Small package exporting a PBKDF2 function that works both in Node.js and in browsers

Notifications You must be signed in to change notification settings

ctrl-alt-deseat/ctrlpanel-pbkdf2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PBKDF2 for Node.js and Browsers

Small package exporting a PBKDF2 function that works both in Node.js and in browsers.

Installation

npm install --save @ctrlpanel/pbkdf2

Usage

const pbkdf2 = require('@ctrlpanel/pbkdf2')

const password = Buffer.from('super secret')
const salt = Buffer.from('salt')

pbkdf2(password, salt, 500000, 32, 'SHA-512').then((result) => {
  console.log(result)
  //=> ArrayBuffer { byteLength: 32 }
})

API

pbkdf2(password, salt, iterations, keylen, digest) => ArrayBuffer

  • password: ArrayBuffer | Uint8Array | Buffer - The password to base the derivation on
  • salt: ArrayBuffer | Uint8Array | Buffer - The salt used when deriving
  • iterations: number - Number of iterations
  • keylen: number - Byte length of output key
  • digest: 'SHA-256' | 'SHA-384' | 'SHA-512' - Hash algorithm to use

Derive a key from password, and return it as an ArrayBuffer.

About

Small package exporting a PBKDF2 function that works both in Node.js and in browsers

Resources

Stars

Watchers

Forks

Packages

No packages published