
Product
Introducing Custom Pull Request Alert Comment Headers
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
blockchain-helper-lib
Advanced tools
A professional utility package for validating sha256 hashes with enhanced error handling
A professional utility package for validating and working with SHA-256 hashes, designed for blockchain, cryptography, and data integrity applications in Node.js. Includes enhanced error handling and TypeScript support.
npm install blockchain-helper-lib
const Sha256Helper = require('blockchain-helper-lib');
import * as Sha256Helper from 'blockchain-helper-lib';
const { validateHashFormat } = require('blockchain-helper-lib');
console.log(validateHashFormat('a3f5...')); // true or false
const { generateSha256 } = require('blockchain-helper-lib');
const hash = generateSha256('hello world');
console.log(hash); // prints SHA-256 hash string
const { compareSha256 } = require('blockchain-helper-lib');
const hash1 = '...';
const hash2 = '...';
console.log(compareSha256(hash1, hash2)); // true if equal, false otherwise
const { syncSha256Validation } = require('blockchain-helper-lib');
try {
const fileHash = syncSha256Validation({ encoding: 'utf8', resolveFromCwd: false });
console.log('File hash:', fileHash);
} catch (err) {
console.error('Validation error:', err.message);
}
const { asyncSha256Validation } = require('blockchain-helper-lib');
asyncSha256Validation({ encoding: 'utf8', resolveFromCwd: false })
.then(hash => console.log('File hash:', hash))
.catch(err => console.error('Validation error:', err.message));
const { hashFileContent } = require('blockchain-helper-lib');
const hash = hashFileContent('path/to/file.txt');
console.log(hash);
const { verifyFileHash } = require('blockchain-helper-lib');
const isValid = verifyFileHash('path/to/file.txt', 'expected_sha256_hash');
console.log(isValid ? 'File is valid' : 'File is NOT valid');
Synchronously validates a file and returns its SHA-256 hash.
options
(object, optional):
encoding
(string): File encoding (default: 'utf8')resolveFromCwd
(boolean): Resolve path from current working directory (default: false)string
(SHA-256 hash)Asynchronously validates a file and returns its SHA-256 hash.
options
(object, optional): Same as abovePromise<string>
Generates a SHA-256 hash from a string.
content
(string): The content to hashoptions
(object, optional):
encoding
(string): Content encoding (default: 'utf8')string
(SHA-256 hash)Checks if a string is a valid SHA-256 hash.
hash
(string): The hash to validateboolean
Compares two SHA-256 hashes for equality.
hash1
(string): First hashhash2
(string): Second hashboolean
Generates a SHA-256 hash from the contents of a file.
filePath
(string): Path to the fileoptions
(object, optional):
encoding
(string): File encoding (default: 'utf8')resolveFromCwd
(boolean): Resolve path from current working directory (default: false)string
(SHA-256 hash)Verifies that a file's contents match an expected SHA-256 hash.
filePath
(string): Path to the fileexpectedHash
(string): The expected SHA-256 hashoptions
(object, optional):
encoding
(string): File encoding (default: 'utf8')resolveFromCwd
(boolean): Resolve path from current working directory (default: false)boolean
MIT
James Edward
Contributions are welcome! Please open an issue or submit a pull request.
FAQs
A professional utility package for validating sha256 hashes with enhanced error handling
The npm package blockchain-helper-lib receives a total of 1,095 weekly downloads. As such, blockchain-helper-lib popularity was classified as popular.
We found that blockchain-helper-lib demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.