This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

sorthash

1.0.5 • Public • Published

sorthash

Encryption library

Current features

  • Hash passwords, with salt
  • Compare passwords
  • Generate random strings composed of numbers or characters

Important to know

You need to store both the password and salt in order to compare later.

Usage of the password hash / compare functions

// Includes sorthash
const sorthash = require("sorthash");
 
// Hashes the password
var password = "Example123";
var saltLength = 20;
 
var { hash, salt } = sorthash.hash(password, saltLength); // Returns something like this: aabbbcchhwwxx11133455
 
// Compares the password
if (sorthash.compare(password, salt, hash)) {
  // -> The passwords match
} else {
  // -> The passwords don't match
}

Usage of the randomstring generator

// Includes sorthash
const sorthash = require("sorthash");
 
// Generates random chars, the length must be between 1 and 500
var chars = sorthash.randomString({
  type: "chars",
  length: 20
});
 
// Generates random numbers
var chars = sorthash.randomString({
  type: "numbers",
  length: 20
});

Package Sidebar

Install

npm i sorthash

Weekly Downloads

1

Version

1.0.5

License

ISC

Unpacked Size

16.3 kB

Total Files

7

Last publish

Collaborators

  • skywa04885