Skip to content
This repository has been archived by the owner on Oct 14, 2020. It is now read-only.

Slynova-Org/hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

hash

Download Version License

hash is a framework-agnostic package which provides a powerful wrapper for password hashing algorithms in Node.js.

There are currently 2 drivers available:

  • Argon2
  • Bcrypt

Getting Started

This package is available in the npm registry. It can easily be installed with npm or yarn.

$ npm i @slynova/hash
# or
$ yarn add @slynova/hash

When you require the package in your file, it will give you access to the HashManager class. This class is a facade for the package and should be instantiated with a configuration object.

const { HashManager } = require('@slynova/hash')
const hash = new HashManager(config)

Once you instantiated the manager, you can use the HashManager#use() method to retrieve a driver an use it.

hash.use() // Returns the default driver (specified in the config)
hash.use('argon2') // Returns the argon2 driver
hash.use('bcrypt', customConfig) // Overwrite the default configuration of the driver

Driver's API

Each driver implements the Interface Hash.

Methods

make(value: string, config?: Argon2Config | BcryptConfig): Promise<string>

This method will hash a plain value using the provided driver.

await hash.use('bcrypt').make('foo')
// $2b$10$RFgHztUoooIJEhuR4/e3ue4lZg36HYcIY2D7ptjB494FI/ctohaa6
verify(value: string, hash: string): Promise<boolean>

This method will verify an existing hash with the plain value using the provided driver.

await hash.use('bcrypt').verify('foo', '$2b$10$RFgHztUoooIJEhuR4/e3ue4lZg36HYcIY2D7ptjB494FI/ctohaa6')

Contribution Guidelines

Any pull requests or discussions are welcome. Note that every pull request providing new feature or correcting a bug should be created with appropriate unit tests.

About

๐Ÿ” Framework-agnostic driver based system for password hashing algorithms in Node.js

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published