Class Password

java.lang.Object
org.moera.lib.crypto.Password

public class Password extends Object
Utility class for password hashing and validation.
  • Constructor Details

    • Password

      public Password()
  • Method Details

    • hash

      public static String hash(String password)
      Generates a hash for the given password using a randomly generated salt.
      Parameters:
      password - the password to be hashed
      Returns:
      the hashed password as a Base64-encoded string that includes the hash and the salt
    • validate

      public static boolean validate(String hash, String password)
      Validates if the provided password matches the given hash, using the salt embedded in the hash.
      Parameters:
      hash - the Base64-encoded string containing the hash and the salt
      password - the password to validate against the hash
      Returns:
      true if the password matches the hash, false otherwise