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

@stablelib/sha512

Package Overview
Dependencies
Maintainers
0
Versions
7
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.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
346K
decreased by-8.06%
Maintainers
0
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 29 Jun 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