🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@stablelib/sha512

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/sha512

SHA-512 cryptographic hash function

2.0.1
latest
Source
npm
Version published
Weekly downloads
336K
6.56%
Maintainers
1
Weekly downloads
 
Created

What is @stablelib/sha512?

@stablelib/sha512 is a JavaScript library that provides a secure and efficient implementation of the SHA-512 cryptographic hash function. It is part of the StableLib collection of cryptographic libraries, which are designed to be secure, fast, and easy to use.

What are @stablelib/sha512's main functionalities?

Hashing a string

This feature allows you to hash a string using the SHA-512 algorithm. The code sample demonstrates how to import the SHA512 class, create a new instance, update it with a message, and then generate the hash digest in hexadecimal format.

const { SHA512 } = require('@stablelib/sha512');
const message = 'Hello, world!';
const hash = new SHA512().update(message).digest();
console.log(Buffer.from(hash).toString('hex'));

Hashing a file

This feature allows you to hash the contents of a file using the SHA-512 algorithm. The code sample demonstrates how to create a read stream for a file, update the hash with each chunk of data, and then generate the hash digest in hexadecimal format once the stream ends.

const { SHA512 } = require('@stablelib/sha512');
const fs = require('fs');
const hash = new SHA512();
const stream = fs.createReadStream('path/to/file');
stream.on('data', (chunk) => hash.update(chunk));
stream.on('end', () => {
  const digest = hash.digest();
  console.log(Buffer.from(digest).toString('hex'));
});

Other packages similar to @stablelib/sha512

FAQs

Package last updated on 03 Jan 2025

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