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.
create-hash
Advanced tools
The create-hash npm package is a utility for creating hash digests of data. It implements the Node.js crypto.createHash API in pure JavaScript, making it compatible with environments where Node's native crypto module is not available. This package supports various hashing algorithms, such as SHA-1, SHA-256, and MD5, allowing users to generate fixed-size hash outputs from input data. It is commonly used for creating unique identifiers, checksums, or for password hashing and data integrity verification.
Creating a SHA-256 hash
This code demonstrates how to create a SHA-256 hash of the string 'hello world'. It uses the 'create-hash' package to create a hash object, updates the hash with the input data, and then outputs the digest in hexadecimal format.
"use strict";\nconst createHash = require('create-hash');\nconst hash = createHash('sha256');\nhash.update('hello world');\nconsole.log(hash.digest('hex'));
Creating an MD5 hash
This example shows how to generate an MD5 hash of the string 'example data'. Similar to the previous example, it creates an MD5 hash object, updates it with the input, and outputs the resulting digest in hex format.
"use strict";\nconst createHash = require('create-hash');\nconst hash = createHash('md5');\nhash.update('example data');\nconsole.log(hash.digest('hex'));
Crypto-js is a package that provides cryptographic functionalities including various hash functions, cipher algorithms, and secure random number generators. Compared to create-hash, crypto-js offers a broader range of cryptographic functions beyond just hashing.
Hash.js is a lightweight hash library that supports several hash algorithms like SHA-1, SHA-256, and SHA-512. While similar in functionality to create-hash, hash.js focuses on being a minimalistic and standalone hash library.
Node style hashes for use in the browser, with native hash functions in node.
API is the same as hashes in node:
var createHash = require('create-hash')
var hash = createHash('sha224')
hash.update('synchronous write') // optional encoding parameter
hash.digest() // synchronously get result with optional encoding parameter
hash.write('write to it as a stream')
hash.end() // remember it's a stream
hash.read() // only if you ended it as a stream though
To get the JavaScript version even in node do require('create-hash/browser')
FAQs
create hashes for browserify
The npm package create-hash receives a total of 8,508,389 weekly downloads. As such, create-hash popularity was classified as popular.
We found that create-hash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
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.