Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The 'sha' npm package is used for generating SHA (Secure Hash Algorithm) hashes. It supports various SHA algorithms like SHA-1, SHA-256, SHA-384, and SHA-512. This package is useful for creating cryptographic hashes of data, which can be used for data integrity checks, password hashing, and more.
Generate SHA-1 Hash
This feature allows you to generate a SHA-1 hash of a given input string. The code sample demonstrates how to create a SHA-1 hash of the string 'Hello World' and output it in hexadecimal format.
const sha = require('sha');
const hash = sha('sha1').update('Hello World').digest('hex');
console.log(hash);
Generate SHA-256 Hash
This feature allows you to generate a SHA-256 hash of a given input string. The code sample demonstrates how to create a SHA-256 hash of the string 'Hello World' and output it in hexadecimal format.
const sha = require('sha');
const hash = sha('sha256').update('Hello World').digest('hex');
console.log(hash);
Generate SHA-384 Hash
This feature allows you to generate a SHA-384 hash of a given input string. The code sample demonstrates how to create a SHA-384 hash of the string 'Hello World' and output it in hexadecimal format.
const sha = require('sha');
const hash = sha('sha384').update('Hello World').digest('hex');
console.log(hash);
Generate SHA-512 Hash
This feature allows you to generate a SHA-512 hash of a given input string. The code sample demonstrates how to create a SHA-512 hash of the string 'Hello World' and output it in hexadecimal format.
const sha = require('sha');
const hash = sha('sha512').update('Hello World').digest('hex');
console.log(hash);
The 'crypto' module is a built-in Node.js module that provides cryptographic functionality, including a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions. It is more comprehensive and versatile compared to 'sha', supporting a wider range of cryptographic operations.
The 'hash.js' package is a JavaScript library that provides a simple way to create hash digests of data. It supports various hash algorithms including SHA-1, SHA-256, SHA-384, and SHA-512. It is similar to 'sha' but offers a more modular approach and additional features like HMAC.
The 'js-sha256' package is a JavaScript implementation of the SHA-256 hash function. It is lightweight and fast, making it suitable for client-side applications. Unlike 'sha', it focuses solely on SHA-256, providing a highly optimized implementation for this specific algorithm.
Check and get file hashes (using any algorithm)
$ npm install sha
Asynchronously check that fileName
has a "hash" of expected
. The callback will be called with either null
or an error (indicating that they did not match).
Options:
sha1
and can be any of the algorithms supported by crypto.createHash
Asynchronously get the "hash" of fileName
. The callback will be called with an optional error
object and the (lower cased) hex digest of the hash.
Options:
sha1
and can be any of the algorithms supported by crypto.createHash
Check the hash of a stream without ever buffering it. This is a pass through stream so you can do things like:
fs.createReadStream('src')
.pipe(sha.stream('expected'))
.pipe(fs.createWriteStream('dest'))
dest
will be a complete copy of src
and an error will be emitted if the hash did not match 'expected'
.
Options:
sha1
and can be any of the algorithms supported by crypto.createHash
You may use this software under the BSD or MIT. Take your pick. If you want me to release it under another license, open a pull request.
FAQs
Check and get file hashes
The npm package sha receives a total of 96,546 weekly downloads. As such, sha popularity was classified as popular.
We found that sha demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.