@ctrlpanel/hkdf
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

HKDF for Node.js and Browsers

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

Installation

npm install --save @ctrlpanel/hkdf

Usage

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

const salt = Buffer.from('salt')
const password = Buffer.from('super secret')
const info = Buffer.from('@ctrlpanel/hkdf')

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

API

hkdf(salt, input, info, keylen, digest) => ArrayBuffer

  • salt: ArrayBuffer | Uint8Array | Buffer - The salt used when deriving, a non-secret random value
  • input: ArrayBuffer | Uint8Array | Buffer - The input key material to base the derivation on
  • info: ArrayBuffer | Uint8Array | Buffer - Context and application specific information
  • keylen: number - Byte length of output key
  • digest: 'SHA-256' | 'SHA-384' | 'SHA-512' - Hash algorithm to use

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

Package Sidebar

Install

npm i @ctrlpanel/hkdf

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • linusu