Hello, fellow devs!
It's been a long time since I have written any new article here. So here is a small tutorial that I find very easy, fun, and also productive.
I'll show you a simple way how you can hash your passwords in node.js using
The example I'm using today is from an API that I am making right now.
First, we will install a library called
bcrypt.js using a simple npm command
npm install bcryptjs and then import it into our project.
And now I'll show the difference between an encrypted request and a not encrypted request made using postman. this is the request code without using bcrypt.js
And this is the response I get.
And now I will use the
hashSync method provided by
bcrypt.js to hash the user password field.
These are the changes required in the code. this is a simple function built into the
And now in the response of the API, the password field will be in hashed form.
This is a simple way to hash your passwords in node.js.
Plus points if you can find the Simpsons reference. :)