Socket
Socket
Sign inDemoInstall

@rabbit-company/blake2b

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rabbit-company/blake2b

Blake2b-512 hash function


Version published
Weekly downloads
18
increased by20%
Maintainers
1
Weekly downloads
 
Created
Source

Blake2b-JS

A JavaScript (ES6) implementation of the Blake2b-512 cryptographic hash function.

Usage

1. Download the library

npm i --save @rabbit-company/blake2b

2. Import the library

import Blake2b from "@rabbit-company/blake2b";

3. Generate a Hash

/**
 * Generate a Blake2b hash.
 *
 * @param {string | Uint8Array} message - The input message to hash (required).
 * @param {string | Uint8Array | undefined} secret - An optional secret key for HMAC mode.
 * @param {number} [length=64] - The length of the hash output in bytes (default is 64, max is 64).
 * @param {string | Uint8Array} [salt] - An optional salt value for the hash (must be 16 bytes long).
 * @param {string | Uint8Array} [personal] - An optional personalization value (must be 16 bytes long).
 * @returns {string} - The hexadecimal representation of the hash.
 */

// Generate hash from the provided message
Blake2b.hash("message");

// Generate hash from the provided message and secret key
Blake2b.hash("message", "secretKey");

// Generate hash from the provided message, secret key and length
Blake2b.hash("message", "secretKey", 32);

// Generate hash from the provided message, secret key, length and salt
Blake2b.hash("message", "secretKey", 32, "c32df5f2f3c77a03");

// Generate hash from the provided message, secret key, length, salt and personal
Blake2b.hash(
	"message",
	"secretKey",
	32,
	"c32df5f2f3c77a03",
	"4862f0260a9803da"
);

Parameters

  • message: The input to be hashed. Can be a string or a Uint8Array.
  • secret: (Optional) A secret key for HMAC mode. Can be a string or Uint8Array. If not provided, a standard Blake2b hash will be generated.
  • length: (Optional) The length of the output hash in bytes. Defaults to 64. Must be between 1 and 64.
  • salt: (Optional) A salt value for the hash. Must be a 16-byte string or Uint8Array.
  • personal: (Optional) A personalization string for the hash. Must be a 16-byte string or Uint8Array.

Keywords

FAQs

Package last updated on 12 Aug 2024

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