Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@aws-crypto/sha256-js
Advanced tools
Package description
The @aws-crypto/sha256-js package is a JavaScript implementation of the SHA-256 hash function. It is part of the AWS SDK for JavaScript and is used to compute SHA-256 cryptographic hash values. This package is particularly useful when working with AWS services that require SHA-256 hashes, such as signing requests for AWS Signature Version 4.
Computing SHA-256 hash
This feature allows you to compute the SHA-256 hash of a given input. The code sample demonstrates how to create a new instance of the Sha256 class, update it with the data to be hashed, and then compute the digest.
const { Sha256 } = require('@aws-crypto/sha256-js');
async function computeHash(data) {
const hash = new Sha256();
hash.update(data);
return hash.digest();
}
computeHash('data to hash').then(console.log);
Crypto-js is a popular package that provides cryptographic functions including SHA-256. It offers a wide range of cryptographic algorithms and is often used for encryption and hashing in JavaScript applications. Compared to @aws-crypto/sha256-js, crypto-js is more general-purpose and not AWS-specific.
js-sha256 is a simple SHA-256 hash function for JavaScript that supports UTF-8 encoding. It is lightweight and has no dependencies. Unlike @aws-crypto/sha256-js, it is not part of the AWS SDK and is designed for general use cases where SHA-256 hashing is needed.
hash.js is a JavaScript hash library that supports several hash functions including SHA-256. It is a pure JavaScript implementation and can be used in various environments. While @aws-crypto/sha256-js is focused on SHA-256 and AWS integration, hash.js provides a broader set of hash functions for different use cases.
Readme
A pure JS implementation SHA256.
import {Sha256} from '@aws-crypto/sha256-js';
const hash = new Sha256();
hash.update('some data');
const result = await hash.digest();
import {Sha256} from '@aws-crypto/sha256-js';
const hash = new Sha256('a key');
hash.update('some data');
const result = await hash.digest();
npm test
FAQs
A pure JS implementation SHA256.
The npm package @aws-crypto/sha256-js receives a total of 13,045,813 weekly downloads. As such, @aws-crypto/sha256-js popularity was classified as popular.
We found that @aws-crypto/sha256-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.