0.1.2 • Published 1 year ago

just-hash v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

JustHash

This is a very simple library that abstracts password hashing for you. There are no dependencies; it uses the crypto module built into node.

CI

import JustHash from 'just-hash';

// This is safe to store in your DB of choice.
// It contains both the salt and hashed value.
const hashed_password = JustHash.hashPassword('password');

// Use validatePassword() to check values against the hash
JustHash.validatePassword('password', hashed_password); // returns true
JustHash.validatePassword('incorrect', hashed_password); // returns false
import JustHash, { HashAlgorithm, TextEncoding } from 'just-hash';

// This is how you would configure the behavior of the library if you so wish.
// This is optional as the library will initialize with default values which
// are perfectly fine to use in most cases.
// What you see below is the default configuration.
JustHash.configure({
    hash_algorithm: HashAlgorithm.sha512;   // algorithm used when hashing data
    output_type: TextEncoding.hex;          // output format of hashed data
    salt_length: 16;                        // number of byte to salt with
    key_length: 64;                         // length to hash passwords to
});