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 aPasswordStrengthrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.doubleCalculates the entropy efficiency of the password as a percentage.Gets the estimated time to crack this password using a modern attack.final inthashCode()Returns a hash code value for this object.booleanisSecure()issues()Returns the value of theissuesrecord component.doubleReturns the value of theshannonEntropyrecord component.Returns the value of thestrengthLevelrecord component.doubleReturns the value of thetheoreticalEntropyrecord 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 aPasswordStrengthrecord class.- Parameters:
shannonEntropy- the value for theshannonEntropyrecord componenttheoreticalEntropy- the value for thetheoreticalEntropyrecord componentstrengthLevel- the value for thestrengthLevelrecord componentissues- the value for theissuesrecord 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 theshannonEntropyrecord component.- Returns:
- the value of the
shannonEntropyrecord component
-
theoreticalEntropy
public double theoreticalEntropy()Returns the value of thetheoreticalEntropyrecord component.- Returns:
- the value of the
theoreticalEntropyrecord component
-
strengthLevel
Returns the value of thestrengthLevelrecord component.- Returns:
- the value of the
strengthLevelrecord component
-
issues
Returns the value of theissuesrecord component.- Returns:
- the value of the
issuesrecord component
-