Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@ethersproject/sha2
Advanced tools
The SHA2 family hash functions and HMAC functions for ethers.
@ethersproject/sha2 is a part of the ethers.js library, which provides utilities for interacting with the Ethereum blockchain. This specific package focuses on SHA-2 hashing algorithms, allowing developers to create secure hashes for data integrity and cryptographic purposes.
SHA-256 Hashing
This feature allows you to create a SHA-256 hash of a given input. SHA-256 is a widely used cryptographic hash function that produces a 256-bit hash value.
const { sha256 } = require('@ethersproject/sha2');
const data = 'Hello, world!';
const hash = sha256(data);
console.log(hash);
SHA-512 Hashing
This feature allows you to create a SHA-512 hash of a given input. SHA-512 is another cryptographic hash function that produces a 512-bit hash value, offering a higher level of security compared to SHA-256.
const { sha512 } = require('@ethersproject/sha2');
const data = 'Hello, world!';
const hash = sha512(data);
console.log(hash);
The 'crypto' module is a built-in Node.js module that provides cryptographic functionality, including a variety of hash functions like SHA-256 and SHA-512. It is more versatile and widely used but may not be as specialized for Ethereum-related tasks as @ethersproject/sha2.
The 'js-sha256' package is a lightweight library for SHA-256 hashing in JavaScript. It is highly optimized for performance and can be used in both Node.js and browser environments. However, it does not support SHA-512 hashing.
The 'sha.js' package is a simple library for SHA family hashing algorithms, including SHA-256 and SHA-512. It is similar in functionality to @ethersproject/sha2 but is not specifically tailored for Ethereum development.
This sub-module is part of the ethers project.
It is responsible for common cryptographic hashes and HMAC.
For more information, see the documentation.
Most users will prefer to use the umbrella package, but for those with more specific needs, individual components can be imported.
const {
ripemd160,
sha256,
sha512,
computeHmac,
// Enums
SupportedAlgorithm
} = require("@ethersproject/sha2");
MIT License
FAQs
The SHA2 family hash functions and HMAC functions for ethers.
The npm package @ethersproject/sha2 receives a total of 810,461 weekly downloads. As such, @ethersproject/sha2 popularity was classified as popular.
We found that @ethersproject/sha2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.