Small package exporting a PBKDF2 function that works both in Node.js and in browsers.
npm install @ctrlpanel/pbkdf2Small package exporting a PBKDF2 function that works both in Node.js and in browsers.
``sh`
npm install --save @ctrlpanel/pbkdf2
`js
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 }
})
`
- password: ArrayBuffer | Uint8Array | Buffer - The password to base the derivation onArrayBuffer | Uint8Array | Buffer
- salt: - The salt used when derivingnumber
- iterations: - Number of iterationsnumber
- keylen: - Byte length of output key'SHA-256' | 'SHA-384' | 'SHA-512'
- digest: - Hash algorithm to use
Derive a key from password, and return it as an ArrayBuffer`.