Socket
Socket
Sign inDemoInstall

futoin-hkdf

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

futoin-hkdf

RFC5869: HMAC-based Extract-and-Expand Key Derivation Function (HKDF)


Version published
Maintainers
1
Created

What is futoin-hkdf?

The futoin-hkdf npm package is a JavaScript implementation of the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869. It is used to derive one or more cryptographic keys from a source key material in a secure manner.

What are futoin-hkdf's main functionalities?

Basic HKDF Derivation

This code demonstrates the basic usage of the futoin-hkdf package to derive a cryptographic key from initial keying material (IKM) using optional salt and info parameters.

const hkdf = require('futoin-hkdf');
const crypto = require('crypto');

const ikm = crypto.randomBytes(32); // Initial Keying Material
const salt = crypto.randomBytes(16); // Optional salt
const info = Buffer.from('info'); // Optional context and application specific information
const length = 32; // Length of the derived key
const hash = 'sha256'; // Hash function to use

const derivedKey = hkdf(ikm, length, { salt, info, hash });
console.log(derivedKey.toString('hex'));

HKDF with Different Hash Functions

This code demonstrates how to use different hash functions (SHA-512 and SHA-1) with the futoin-hkdf package to derive cryptographic keys.

const hkdf = require('futoin-hkdf');
const crypto = require('crypto');

const ikm = crypto.randomBytes(32); // Initial Keying Material
const salt = crypto.randomBytes(16); // Optional salt
const info = Buffer.from('info'); // Optional context and application specific information
const length = 32; // Length of the derived key

// Using SHA-512 hash function
const derivedKeySHA512 = hkdf(ikm, length, { salt, info, hash: 'sha512' });
console.log(derivedKeySHA512.toString('hex'));

// Using SHA-1 hash function
const derivedKeySHA1 = hkdf(ikm, length, { salt, info, hash: 'sha1' });
console.log(derivedKeySHA1.toString('hex'));

Other packages similar to futoin-hkdf

Keywords

FAQs

Package last updated on 27 Sep 2019

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