Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Chapi provides a compatible API for different hashing algorithms.
Chapi provides two ways of accessing hashing functions, you can use it as a function, or an object.
The function signature looks like this:
function(algorithm, options);
The other way of using it, is accessing the property name of the algorithm you would like to use, that property is a function which you can pass an optional configuration object to. Like this:
chapi.bcrypt()
Each hashing API provides 2 functions, being hash
and compare
.
The hash function takes a string, and a callback. It performs the actually computation of the hash of str
and stores any needed information in the hash you get back.
The signature of the callback you pass should be function(err, hash)
The compare function takes a string, a hash, and a callback. It calculates the hash of str
(using the options from hash
, if necessary) and compares it to hash
.
The signature of the callback you pass should be function(err, match)
var chapi = require("chapi");
var async = require("async");
var algorithms = [ "bcrypt", "pbkdf2", "scrypt", "sha256" ];
var data = "hello world! so original.";
// Iterate over each algorithm in array
async.map(algorithms, function(algorithm, done) {
// Call the `hash` function and pass in data & callback
chapi[algorithm]().hash(data, done);
}, function(err, hashes) {
// Check for errors..
if(err) {
return console.error("Error hashing:", err);
}
console.log("Hashes:", hashes);
// Hashes contains the uniquely hashed string using each algorithm.
});
var chapi = require("chapi");
var plaintext = "omg not something random words";
var algorithm = "bcrypt";
chapi[algorithm].hash(plaintext, function(err, hash) {
if(err) return console.error("Error hashing:", err);
chapi[algorithm].compare(plaintext, hash, function(err, match) {
if(err) return console.error("Error verifying:", err);
console.log("Hash matched:", match);
});
});
See LICENSE.md
FAQs
Compatible hashing API for NodeJS
The npm package chapi receives a total of 4 weekly downloads. As such, chapi popularity was classified as not popular.
We found that chapi 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.