From the course: Master Next.js by Building Scalable Apps with Routing, Databases, and Performance

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Implementing hashing

Implementing hashing

Alright, so we have successfully added the new user, but while storing the password, we cannot directly store the password without any encryption. The ideal approach is to hash the password, and for hashing, we can use the external libraries like bcrypt, crypto, etc. But we will be using the bcrypt as it is more widely used and is compatible with many technologies. So let me open the terminal and install the bcrypt by writing npm install bcrypt. Alright now to hash a password, we need to follow a process. For hashing we need to generate a salt. Now what is a salt? Password is a string of random characters which can be joined to a string to make it more secure and difficult to guess. For example, I have the password example at 123. Then to make it more tough to guess, I can add a couple of random characters which do not have any importance in the value, but instead, they are just to make the string more complex and unpredictable. Now we can generate the salt using bcrypt itself. So…

Contents