Skip to content

sinuoslabs/nestjs-hasher

Repository files navigation

Nestjs Hasher

NestJS Hasher, is a module that combines several hash libraries into one such as bcrypt and argon. You can use them separately, without affecting anything. This library works only with the NestJS framework.

Contents

Installation

To use the library you must execute the command below in your project.

$ npm install @sinuos/nestjs-hasher

Usage

To use this library, you must declare the module in AppModule

Bcrypt

This integration works with this package Bcrypt

import { Module } from '@nestjs/common';
import { NestjsHasherModule } from 'nestjs-hasher';

@Module({
  imports: [
    NestjsHasherModule.register({
      provider: 'bcrypt',
      round: 10,
    }),
  ],
})
export class AppModule {}

Argon

This integration works with this package Argon

import { Module } from '@nestjs/common';
import { NestjsHasherModule } from 'nestjs-hasher';

@Module({
  imports: [
    NestjsHasherModule.register({
      provider: 'argon',
    }),
  ],
})
export class AppModule {}

Service

import { Injectable } from '@nestjs/common';
import { NestjsHasherService } from '@sinuos/nestjs-haasher';

@Injectable()
export class AppService {
    constructor(private readonly service: NestjsHasherService) { }
}

Available methods

Hash

hash(plainText) to hash a string

Check

check(plainText, hashedValue) to check if hashed value matched with your string

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ npm run test

Security

If you discover any security related issues, please email dao.houssene@gmail.com instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.