In this video.
Let's finish up with the user registration.
The problem that we are facing is that if we leave as it is, that is how we are registering the user
and save it into our division.
Here you can see we are saving the plane password inside our database.
So let's say in future our application compromise.
In that way we are exposing this particular user into problems.
It can happen that this user uses the same password for his or her banking transaction.
So in this way we are exposing this user into problem.
If a hacker got to know the details about the user.
So instead of saving the plain password, we are going to save random string of characters into our.
So we need to install a package to get it done.
So let's get back to our terminal and let's shut down and let me clear the terminal and install a package
called Big Crypt JS.
And it just finished installing.
So let me restart the server.
If you have taken some of my courses, you can see that I always hash the user password inside the module,
but for this one I'm going to do it inside the controller.
So let's get back to the user controller and let's require the package as be equipped, be equipped.
Geez.
So let me bring the custom input below the default ones or the installed packages.
So now here we go.
Before we save the user, we need to hash the user password before saving it here.
So first step is that we need to create a salt so it's equal to a weight.
And then the big crypt dot change salt.
So we need this one with a combination with the plane password to be able to generate the random string
of characters.
And here we provide the number.
So the higher the number, the more secure the salt is going to be, but the higher the number also
is going to slow down your application.
So the recommended number is ten.
The next step is that we need to hash we're going to be as concerned and call this one as password hashed.
Is equal to A weight and B grapes dot hash then pass in the plane password, which is this one.
And then the sort we got, which is this one.
So now we are going to save this one instead of the plane password and that is it.
So let's go ahead and register a user.
So here, register and let me change this one to John and going to be as John at gmail.com.
And it's sent.
You can see that the user has been registered, but instead of playing password, we are saving this
random string of characters.
So the question is, how can we log in?
Are you going to memorize all these characters here?
The answer is no.
We are going to get back the main password by verifying this one.
So let's see how we are going to look in in the next video.