Socket
Socket
Sign inDemoInstall

fastify-bcrypt-plugin

Package Overview
Dependencies
63
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fastify-bcrypt-plugin

A Bcrypt hash generator & checker for Fastify


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

fastify-bcrypt-plugin

Version

A Bcrypt hash generator & checker for Fastify

Installation

yarn add fastify-bcrypt-plugin
or
npm install fastify-bcrypt-plugin

Usage

Register plugin

import fastifyBcrypt from "fastify-bcrypt-plugin";

fastify.register(fastifyBcrypt);

If you use with TypeScript , you have to give this type to avoid error

import Fastify, { FastifyInstance } from "fastify";

const fastify: FastifyInstance = Fastify();

If you want to change the salt work factor

fastify.register(fastifyBcrypt, { saltOrRounds: 15 }); // The salt work factor for the bcrypt algorithm. The default value is 10.

Use with fastify decorate

fastify.get("/", async (request, reply) => {
  const hashedPassword = await fastify.bcrypt.hash(request.body.password);
  const isPasswordCompared = await fastify.bcrypt.compare(
    request.body.password,
    hashedPassword
  );
  return { hashedPassword, isPasswordCompared };
});

Use with request decorate

fastify.get("/", async (request, reply) => {
  const hashedPassword = await request.bcrypt.hash(request.body.password);
  const isPasswordCompared = await request.bcrypt.compare(
    request.body.password,
    hashedPassword
  );
  return { hashedPassword, isPasswordCompared };
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Keywords

FAQs

Last updated on 18 Aug 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc