Awesome
adonis5-pbkdf2
A package that adds PBKDF2 to the hashers of Adonisjs v5.
Installation
Install adonis5-pbkdf2
via npm
or yarn
:
npm install adonis5-pbkdf2
//Or, with yarn: yarn add adonis5-pbkdf2
Configure
After the package has been installed, you have to configure it by running a command:
node ace configure adonis5-pbkdf2
Then, you need to edit your .env
file to add or edit the HASH_DRIVER
key:
HASH_DRIVER=pbkdf2
If you want to also allow typescript to typecheck the .env file, edit the env.ts
file and add the following line:
export default Env.rules({
//....
HASH_DRIVER: Env.schema.enum(['bcrypt','argon','pbkdf2'] as const), //<---- add this line
})
Usage
You can use pbfdf2 through the Hash class, like any other hasher:
import Hash from '@ioc:Adonis/Core/Hash'
const hashedPassword = await Hash.make("hello world")