Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/hash

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/hash

Multi driver hash module with support for PHC string formats

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
decreased by-47.05%
Maintainers
2
Weekly downloads
 
Created
Source

Password hashing

Module to hash values with support for PHC string format

circleci-image npm-image license-image

This module is used by AdonisJs to hash user password with first class support for upgrading logic. A big thanks to the author of uphash, who inspired me to use PHC string format. I would have used uphash directly, but the user facing API is different from what I desire.

Table of contents

Features

  1. Support for multiple hashing algorithms.
  2. Option to extend and add your own hashing algorithms.
  3. Wraps the hash output to a PHC string format, this allows upgrading user passwords, when the underlying configuration changes.

Usage

Install the package from npm registry as follows:

npm i @adonisjs/hash

# yarn
yarn add @adonisjs/hash

and then use it as follows:

import { Hash } from '@adonisjs/hash/build/standalone'
const hash = new Hash({}, config)

const hashedValue = await hash.hash('password')
await hash.verify(hashedValue)

await hash.needsRehash(hashedValue) // false

Using with AdonisJs

The @adonisjs/core module includes this module by default. However, here's how you can set it up manually.

const providers = [
  '@adonisjs/hash/build/providers/HashProvider'
]

And then also register the typings file inside tsconfig.json file.

{
  "files": ["./node_modules/@adonisjs/hash/build/adonis-typings/hash.d.ts"]
}

And use it as follows:

import Hash from '@ioc:Adonis/Core/Hash'
await Hash.hash('password')

Switching drivers

You can switch drivers using the use method.

await Hash.use('bcrypt').hash('password')

API Docs

Following are the autogenerated files via Typedoc

Maintainers

Harminder virk

Keywords

FAQs

Package last updated on 06 Sep 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc