Class PasswordEncoder

java.lang.Object
com.serinity.accesscontrol.util.PasswordEncoder

public final class PasswordEncoder extends Object
Utility class for securely encoding and verifying passwords.

This class provides static methods to encode plain-text passwords using the BCrypt hashing algorithm and to verify passwords against their hashed counterparts.

Important: This class is final and has a private constructor to prevent instantiation, as it is intended to be a pure utility class.

// Example usage
String hashed = PasswordEncoder.encode("mySecretPassword");
boolean matches = PasswordEncoder.isConfirmPassword("mySecretPassword", hashed);

This class is suitable for storing password hashes securely in databases and for verifying user-provided passwords during authentication.

Since:
2026-02-03
Version:
1.1
Author:
@ZouariOmar (zouariomar20@gmail.com)
See Also:
  • Method Details

    • encode

      public static final String encode(String passwd)
      Encodes a plain-text password using the BCrypt hashing algorithm.
      Parameters:
      passwd - the plain-text password to encode; must not be null
      Returns:
      the hashed password as a String
    • isConfirmPassword

      public static final boolean isConfirmPassword(String passwd, String confirmPasswd)
      Verifies if a plain-text password matches a previously encoded hash.
      Parameters:
      passwd - the plain-text password to verify
      confirmPasswd - the previously hashed password
      Returns:
      true if the plain-text password matches the hash, false otherwise