Package com.dua3.utility.crypt
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 spacestrengthLevel
- the overall strength levelissues
- 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 Summary
ConstructorsConstructorDescriptionPasswordStrength
(double shannonEntropy, double theoreticalEntropy, PasswordUtil.StrengthLevel strengthLevel, List<String> issues) Creates an instance of aPasswordStrength
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.double
Calculates the entropy efficiency of the password as a percentage.Gets the estimated time to crack this password using a modern attack.final int
hashCode()
Returns a hash code value for this object.boolean
isSecure()
issues()
Returns the value of theissues
record component.double
Returns the value of theshannonEntropy
record component.Returns the value of thestrengthLevel
record component.double
Returns the value of thetheoreticalEntropy
record component.toString()
Returns a string representation of this record class.
-
Constructor Details
-
PasswordStrength
public PasswordStrength(double shannonEntropy, double theoreticalEntropy, PasswordUtil.StrengthLevel strengthLevel, List<String> issues) Creates an instance of aPasswordStrength
record class.- Parameters:
shannonEntropy
- the value for theshannonEntropy
record componenttheoreticalEntropy
- the value for thetheoreticalEntropy
record componentstrengthLevel
- the value for thestrengthLevel
record componentissues
- the value for theissues
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
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
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. -
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. -
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
shannonEntropy
public double shannonEntropy()Returns the value of theshannonEntropy
record component.- Returns:
- the value of the
shannonEntropy
record component
-
theoreticalEntropy
public double theoreticalEntropy()Returns the value of thetheoreticalEntropy
record component.- Returns:
- the value of the
theoreticalEntropy
record component
-
strengthLevel
Returns the value of thestrengthLevel
record component.- Returns:
- the value of the
strengthLevel
record component
-
issues
Returns the value of theissues
record component.- Returns:
- the value of the
issues
record component
-