A progressive Node.js framework for building efficient and scalable server-side applications.
Bcrypt Module for Nest.
$ npm install nest-bcrypt
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { BcryptModule } from 'nest-bcrypt';
@Module({
imports: [BcryptModule.register({ salt: 10 })],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { BcryptService } from 'nest-bcrypt';
@Injectable()
export class AppService {
constructor(private readonly bcryptService: BcryptService) {}
public async hashData(data: string) {
// return this.bcryptService.hash(data, _customSalt) // to use a custom salt different from that set
return this.bcryptService.hash(data);
}
}
- Author - Joseph Tsegen
- Twitter - @Tsegs_tech
nest-bcrypt is MIT licensed.