Recall & Review
beginner
What is BCrypt in the context of password encoding?
BCrypt is a password hashing function designed to securely encode passwords by adding a salt and using multiple rounds of hashing to protect against brute-force attacks.
Click to reveal answer
beginner
How do you create a BCrypt password encoder in Spring Boot?
You create a BCrypt password encoder by defining a bean like this:
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}Click to reveal answer
intermediate
Why is it important to use a salt in password encoding?
A salt adds random data to the password before hashing, making each hash unique even if two users have the same password. This prevents attackers from using precomputed tables to crack passwords.
Click to reveal answer
beginner
How do you verify a raw password against a BCrypt encoded password in Spring Boot?
Use the matches method of PasswordEncoder:
passwordEncoder.matches(rawPassword, encodedPassword)It returns true if the raw password matches the encoded one.
Click to reveal answer
intermediate
What is the default strength (log rounds) of BCryptPasswordEncoder in Spring Boot?
The default strength is 10, which means 2^10 (1024) rounds of hashing are applied to make password encoding slower and more secure.
Click to reveal answer
What does BCrypt add to passwords before hashing to improve security?
✗ Incorrect
BCrypt adds a random salt to each password before hashing to ensure uniqueness and prevent rainbow table attacks.
Which Spring Boot class is commonly used for BCrypt password encoding?
✗ Incorrect
BCryptPasswordEncoder is the standard Spring Boot class for encoding passwords with BCrypt.
How do you check if a raw password matches an encoded BCrypt password in Spring Boot?
✗ Incorrect
The matches method compares a raw password with an encoded one and returns true if they match.
What is the effect of increasing the strength parameter in BCryptPasswordEncoder?
✗ Incorrect
Increasing strength increases the number of hashing rounds, which slows down encoding but improves security.
Why should you never store raw passwords in your database?
✗ Incorrect
Storing raw passwords is dangerous because if the database is compromised, attackers get direct access to user passwords.
Explain how BCrypt protects passwords and why it is preferred over simple hashing.
Think about how adding randomness and time cost helps security.
You got /4 concepts.
Describe how to implement password encoding and verification using BCrypt in a Spring Boot application.
Focus on the key methods and bean setup.
You got /4 concepts.