New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stablelib/poly1305

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/poly1305

Poly1305 one-time message authentication code

0.0.1
Source
npm
Version published
Weekly downloads
306K
-7.83%
Maintainers
1
Weekly downloads
 
Created

What is @stablelib/poly1305?

@stablelib/poly1305 is a JavaScript implementation of the Poly1305 message authentication code (MAC) algorithm. It is part of the StableLib collection of cryptographic libraries and is designed to provide high-performance and secure MAC generation for use in various cryptographic protocols.

What are @stablelib/poly1305's main functionalities?

Generate Poly1305 MAC

This feature allows you to generate a Poly1305 MAC for a given message using a 32-byte key. The code sample demonstrates how to create a Poly1305 instance, update it with a message, and then generate the MAC.

const { Poly1305 } = require('@stablelib/poly1305');

const key = new Uint8Array(32); // 32-byte key
const message = new Uint8Array([1, 2, 3, 4, 5]); // Message to authenticate

const poly1305 = new Poly1305(key);
poly1305.update(message);
const mac = poly1305.finish();

console.log('MAC:', mac);

Verify Poly1305 MAC

This feature allows you to verify a Poly1305 MAC for a given message and key. The code sample demonstrates how to create a Poly1305 instance, update it with a message, and then compare the generated MAC with an expected MAC.

const { Poly1305 } = require('@stablelib/poly1305');

const key = new Uint8Array(32); // 32-byte key
const message = new Uint8Array([1, 2, 3, 4, 5]); // Message to authenticate
const expectedMac = new Uint8Array(16); // Expected MAC

const poly1305 = new Poly1305(key);
poly1305.update(message);
const isValid = poly1305.finish().every((byte, index) => byte === expectedMac[index]);

console.log('MAC is valid:', isValid);

Other packages similar to @stablelib/poly1305

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