0
0
Node.jsframework~20 mins

Password hashing with bcrypt in Node.js - Mini Project: Build & Apply

Choose your learning style9 modes available
Password hashing with bcrypt in Node.js
📖 Scenario: You are building a simple user registration system. To keep user passwords safe, you need to hash them before saving.
🎯 Goal: Create a Node.js script that uses bcrypt to hash a plain password securely.
📋 What You'll Learn
Create a variable with the plain password string exactly as specified
Set a salt rounds variable for bcrypt configuration
Use bcrypt to hash the password with the salt rounds
Export or log the hashed password variable
💡 Why This Matters
🌍 Real World
Password hashing is essential for protecting user credentials in web applications to prevent password theft.
💼 Career
Understanding bcrypt hashing is a key skill for backend developers working on authentication and security.
Progress0 / 4 steps
1
Set up the plain password variable
Create a variable called plainPassword and set it to the string "MySecret123".
Node.js
Need a hint?

Use const to declare the variable and assign the exact string.

2
Set the salt rounds for bcrypt
Create a variable called saltRounds and set it to the number 10.
Node.js
Need a hint?

Use const and assign the number 10 exactly.

3
Hash the password using bcrypt
Import bcrypt at the top. Then create an async function called hashPassword that uses bcrypt.hash with plainPassword and saltRounds. Inside the function, assign the hashed result to a variable called hashedPassword and return it.
Node.js
Need a hint?

Use import bcrypt from 'bcrypt'; and an async function with await bcrypt.hash() and return hashedPassword;.

4
Export the hashed password function
Add export default hashPassword; at the end of the file to export the hashPassword function.
Node.js
Need a hint?

Use export default followed by the function name.