Package main.Utils

Class Encryptor

java.lang.Object
main.Utils.Encryptor

public class Encryptor extends Object
Provide methods to hash password and verify password
Since:
2023-4-13
  • Constructor Details

    • Encryptor

      public Encryptor(String password)
      Base constructor for Encryptor class
      Parameters:
      password - user input password
  • Method Details

    • generateSalt

      public String 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

      public String generateHashedPassword(byte[] salt)
      Method to convert byte array to String
      Parameters:
      salt - salt for hashing
      Returns:
      hashed password as String
    • verifyUserPassword

      public boolean verifyUserPassword(String providedPassword, String securedPassword, String salt)
      Method to verify user input password with actual password
      Parameters:
      providedPassword - password user inputted
      securedPassword - actual password as hash
      salt - salt for hashing
      Returns:
      True is password matches; False if does not match
    • convertSalt

      public byte[] convertSalt(String salt)
      Convert salt from type String to Byte array
      Parameters:
      salt - salt for hashing as String
      Returns:
      salt as Byte array