Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stablelib/hmac

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/hmac

Hash-based message authentication code (HMAC)

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
194K
increased by3.24%
Maintainers
1
Weekly downloads
 
Created

What is @stablelib/hmac?

@stablelib/hmac is a JavaScript library that provides HMAC (Hash-based Message Authentication Code) functionality. It is part of the StableLib collection of cryptographic libraries, which are designed to be secure, efficient, and easy to use.

What are @stablelib/hmac's main functionalities?

HMAC Generation

This feature allows you to generate an HMAC using a specified hash function (in this case, SHA-256) and a key. The code sample demonstrates how to create an HMAC instance, update it with a message, and then generate the HMAC digest.

const { HMAC } = require('@stablelib/hmac');
const { SHA256 } = require('@stablelib/sha256');

const key = new Uint8Array([1, 2, 3, 4, 5]);
const message = new Uint8Array([6, 7, 8, 9, 10]);

const hmac = new HMAC(SHA256, key);
const mac = hmac.update(message).digest();
console.log(mac);

HMAC Verification

This feature allows you to verify an HMAC against an expected value. The code sample demonstrates how to create an HMAC instance, generate the HMAC digest, and then verify it against an expected MAC value.

const { HMAC } = require('@stablelib/hmac');
const { SHA256 } = require('@stablelib/sha256');

const key = new Uint8Array([1, 2, 3, 4, 5]);
const message = new Uint8Array([6, 7, 8, 9, 10]);
const expectedMac = new Uint8Array([/* expected MAC bytes */]);

const hmac = new HMAC(SHA256, key);
const mac = hmac.update(message).digest();

const isValid = HMAC.verify(SHA256, key, message, expectedMac);
console.log(isValid);

Other packages similar to @stablelib/hmac

FAQs

Package last updated on 16 Apr 2017

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