Package main.Utils
Class Encryptor
java.lang.Object
main.Utils.Encryptor
Provide methods to hash password and verify password
- Since:
- 2023-4-13
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]convertSalt(String salt) Convert salt from type String to Byte arraygenerateHashedPassword(byte[] salt) Method to convert byte array to StringMethod to generate salt for hashingbyte[]hash(byte[] salt) Method for hashing passwordbooleanverifyUserPassword(String providedPassword, String securedPassword, String salt) Method to verify user input password with actual password
-
Constructor Details
-
Encryptor
Base constructor for Encryptor class- Parameters:
password- user input password
-
-
Method Details
-
generateSalt
Method to generate salt for hashing- Returns:
- salt for hasing as byte array
-
hash
public byte[] hash(byte[] salt) Method for hashing password- Parameters:
salt- salt for hashing- Returns:
- hashed password as byte array
-
generateHashedPassword
Method to convert byte array to String- Parameters:
salt- salt for hashing- Returns:
- hashed password as String
-
verifyUserPassword
Method to verify user input password with actual password- Parameters:
providedPassword- password user inputtedsecuredPassword- actual password as hashsalt- salt for hashing- Returns:
- True is password matches; False if does not match
-
convertSalt
Convert salt from type String to Byte array- Parameters:
salt- salt for hashing as String- Returns:
- salt as Byte array
-