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

fast-sha256

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-sha256

SHA-256, HMAC and PBKDF2 implementation with typed arrays for modern browsers and Node.js

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
252K
decreased by-6.28%
Maintainers
1
Weekly downloads
 
Created

What is fast-sha256?

The fast-sha256 npm package is a JavaScript implementation of the SHA-256 hash function. It is designed to be fast and efficient, making it suitable for use in environments where performance is critical.

What are fast-sha256's main functionalities?

Hashing a string

This feature allows you to hash a string using the SHA-256 algorithm. The code sample demonstrates how to encode a string into a Uint8Array, hash it, and then convert the hash value to a hexadecimal string.

const { hash } = require('fast-sha256');
const encoder = new TextEncoder();
const data = encoder.encode('Hello, world!');
const hashValue = hash(data);
console.log(Buffer.from(hashValue).toString('hex'));

Hashing a file

This feature allows you to hash the contents of a file using the SHA-256 algorithm. The code sample demonstrates how to read a file into a buffer, hash it, and then convert the hash value to a hexadecimal string.

const { hash } = require('fast-sha256');
const fs = require('fs');
const data = fs.readFileSync('path/to/file');
const hashValue = hash(data);
console.log(Buffer.from(hashValue).toString('hex'));

Incremental hashing

This feature allows you to perform incremental hashing, which is useful for hashing data that is received in chunks. The code sample demonstrates how to create a Hash instance, update it with multiple chunks of data, and then obtain the final hash value.

const { Hash } = require('fast-sha256');
const hash = new Hash();
hash.update(new TextEncoder().encode('Hello, '));
hash.update(new TextEncoder().encode('world!'));
const hashValue = hash.digest();
console.log(Buffer.from(hashValue).toString('hex'));

Other packages similar to fast-sha256

Keywords

FAQs

Package last updated on 16 Jan 2020

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