Record Class PasswordUtil.PasswordStrength

java.lang.Object
java.lang.Record
com.dua3.utility.crypt.PasswordUtil.PasswordStrength
Record Components:
shannonEntropy - the Shannon entropy in bits (measures randomness)
theoreticalEntropy - the theoretical maximum entropy based on character space
strengthLevel - the overall strength level
issues - list of identified issues with the password
Enclosing class:
PasswordUtil

public static record PasswordUtil.PasswordStrength(double shannonEntropy, double theoreticalEntropy, PasswordUtil.StrengthLevel strengthLevel, List<String> issues) extends Record
Contains password strength analysis results.
  • Constructor Details

    • PasswordStrength

      public PasswordStrength(double shannonEntropy, double theoreticalEntropy, PasswordUtil.StrengthLevel strengthLevel, List<String> issues)
      Creates an instance of a PasswordStrength record class.
      Parameters:
      shannonEntropy - the value for the shannonEntropy record component
      theoreticalEntropy - the value for the theoreticalEntropy record component
      strengthLevel - the value for the strengthLevel record component
      issues - the value for the issues record component
  • Method Details

    • isSecure

      public boolean isSecure()
      Returns:
      true if the password is considered secure (Strong or Very Strong)
    • getEntropyEfficiency

      public double getEntropyEfficiency()
      Calculates the entropy efficiency of the password as a percentage. This measures how well the password uses its available character space. Lower efficiency indicates patterns, repetition, or predictable structure.
      Returns:
      the entropy efficiency percentage (0-100), or 0 if theoretical entropy is zero
    • getEstimatedCrackTime

      public String getEstimatedCrackTime()
      Gets the estimated time to crack this password using a modern attack. This is a rough estimate based on theoretical entropy and assumes an attacker can try 10^12 combinations per second.
      Returns:
      a human-readable string describing the estimated crack time
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • shannonEntropy

      public double shannonEntropy()
      Returns the value of the shannonEntropy record component.
      Returns:
      the value of the shannonEntropy record component
    • theoreticalEntropy

      public double theoreticalEntropy()
      Returns the value of the theoreticalEntropy record component.
      Returns:
      the value of the theoreticalEntropy record component
    • strengthLevel

      public PasswordUtil.StrengthLevel strengthLevel()
      Returns the value of the strengthLevel record component.
      Returns:
      the value of the strengthLevel record component
    • issues

      public List<String> issues()
      Returns the value of the issues record component.
      Returns:
      the value of the issues record component