Class ShannonEntropy

java.lang.Object
org.passay.entropy.ShannonEntropy
All Implemented Interfaces:
Entropy

public final class ShannonEntropy extends Object implements Entropy
Entropy bits estimate defined in NIST SP-800-63-1 User Selected Passwords.

See PDF Publication A1. "User Selected Passwords"

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final double
    Entropy bonus of the first phase.
    private static final int
    Length of the first phase.
    private final boolean
    Whether at least 1 uppercase and special/symbol character is enforced.
    private final boolean
    Whether a dictionary was used to check the password.
    private final int
    Size of the password.
    private static final double
    Entropy bonus of the second phase.
    private static final int
    Length of the second phase.
    private static final int[]
    Array used for determining composition "bonus" for calculating the Shannon entropy estimate.
    private static final int[]
    Array used for determining dictionary entropy "bonus" for calculating the Shannon entropy estimate.
    private static final double
    Entropy bonus of the third phase.
    private static final int
    Length of the second phase.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ShannonEntropy(boolean dictionaryCheck, boolean compositionCheck, int pwordSize)
    Creates a new shannon entropy estimate.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the entropy bits of a user selected password.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FIRST_PHASE_LENGTH

      private static final int FIRST_PHASE_LENGTH
      Length of the first phase.
      See Also:
    • SECOND_PHASE_LENGTH

      private static final int SECOND_PHASE_LENGTH
      Length of the second phase.
      See Also:
    • THIRD_PHASE_LENGTH

      private static final int THIRD_PHASE_LENGTH
      Length of the second phase.
      See Also:
    • FIRST_PHASE_BONUS

      private static final double FIRST_PHASE_BONUS
      Entropy bonus of the first phase.
      See Also:
    • SECOND_PHASE_BONUS

      private static final double SECOND_PHASE_BONUS
      Entropy bonus of the second phase.
      See Also:
    • THIRD_PHASE_BONUS

      private static final double THIRD_PHASE_BONUS
      Entropy bonus of the third phase.
      See Also:
    • SHANNON_DICTIONARY_SIEVE

      private static final int[] SHANNON_DICTIONARY_SIEVE
      Array used for determining dictionary entropy "bonus" for calculating the Shannon entropy estimate.
    • SHANNON_COMPOSITION_SIEVE

      private static final int[] SHANNON_COMPOSITION_SIEVE
      Array used for determining composition "bonus" for calculating the Shannon entropy estimate.
    • hasDictionaryCheck

      private final boolean hasDictionaryCheck
      Whether a dictionary was used to check the password.
    • hasCompositionCheck

      private final boolean hasCompositionCheck
      Whether at least 1 uppercase and special/symbol character is enforced.
    • passwordSize

      private final int passwordSize
      Size of the password.
  • Constructor Details

    • ShannonEntropy

      public ShannonEntropy(boolean dictionaryCheck, boolean compositionCheck, int pwordSize)
      Creates a new shannon entropy estimate.
      Parameters:
      dictionaryCheck - whether or not a common passwords dictionary is checked against the password (50,000 dictionary words are recommended)
      compositionCheck - whether at least 1 uppercase and special/symbol character is enforced (not using common substitutions such as s to $ are recommended)
      pwordSize - size of the password
  • Method Details

    • estimate

      public double estimate()
      Returns the entropy bits of a user selected password. This estimate is based on a 94 Character Alphabet and is a "ballpark" estimate based on Claude Shannon's observations.

      See PDF Publication A1. "User Selected Passwords"

      Specified by:
      estimate in interface Entropy
      Returns:
      estimated entropy bits given password properties