java.lang.Object
com.example.project.services.PasswordHasher
Hashes passwords.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkPassword
(String candidate, String hashed) Verifies a candidate password against a hashed password.static String
hashPassword
(String rawPassword) Hashes a raw password using BCrypt.
-
Constructor Details
-
PasswordHasher
public PasswordHasher()
-
-
Method Details
-
hashPassword
Hashes a raw password using BCrypt.- Parameters:
rawPassword
- the plain text password- Returns:
- the hashed password string
-
checkPassword
Verifies a candidate password against a hashed password.- Parameters:
candidate
- the plain text password entered by the userhashed
- the hashed password stored in the database- Returns:
- true if the password matches, false otherwise
-