Class BaseMatch

java.lang.Object
me.gosimple.nbvcxz.matching.match.BaseMatch
All Implemented Interfaces:
Match
Direct Known Subclasses:
BruteForceMatch, DateMatch, DictionaryMatch, RepeatMatch, SeparatorMatch, SequenceMatch, SpacialMatch, YearMatch

public abstract class BaseMatch extends Object implements Match
Abstract class which takes care of a lot of the boiler plate for implementing Match.
Author:
Adam Brusselback
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Configuration
     
    protected static final double
     
    protected static final double
     
    protected static final double
     
    protected static final double
     
    protected static final double
     
    protected static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseMatch(String match, Configuration configuration, int start_index, int end_index)
    Create a new BaseMatch
  • Method Summary

    Modifier and Type
    Method
    Description
    final double
    Calculate the entropy for the current match
    double
    Get the average entropy per character of the current match
    Returns details about this match in the form of a String to be printed directly
    int
    Returns the end index of this part of the password
    int
    Returns the length of this part of the password
    int
    Returns the start index of this part of the password
     
    protected static double
    log2(double value)
    Calculate the base 2 logarithm of a value
    protected static long
    nCk(int n, int k)
    Calculate binomial coefficients (the number of possible "choose k among n")
    protected void
    setEntropy(double entropy)
     

    Methods inherited from class java.lang.Object

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

    • LOG_2

      protected static final double LOG_2
    • LOG_10

      protected static final double LOG_10
    • LOG_26

      protected static final double LOG_26
    • LOG_129

      protected static final double LOG_129
    • LOG_37200

      protected static final double LOG_37200
    • LOG_47988

      protected static final double LOG_47988
    • configuration

      protected final Configuration configuration
  • Constructor Details

    • BaseMatch

      public BaseMatch(String match, Configuration configuration, int start_index, int end_index)
      Create a new BaseMatch
      Parameters:
      match - the String we are creating the BaseMatch from.
      configuration - the Configuration object.
      start_index - the start index in the password for this match.
      end_index - the end index in the password for this match.
  • Method Details

    • log2

      protected static double log2(double value)
      Calculate the base 2 logarithm of a value
      Parameters:
      value - the double we are calculating the log from
      Returns:
      double
    • nCk

      protected static long nCk(int n, int k)
      Calculate binomial coefficients (the number of possible "choose k among n")
      Parameters:
      n - the total size of the set
      k - the size of the selection
      Returns:
      the binomial coefficient
    • setEntropy

      protected void setEntropy(double entropy)
    • calculateEntropy

      public final double calculateEntropy()
      Description copied from interface: Match
      Calculate the entropy for the current match
      Specified by:
      calculateEntropy in interface Match
      Returns:
      a double representing the entropy of the current Match.
    • getAverageEntropy

      public double getAverageEntropy()
      Description copied from interface: Match
      Get the average entropy per character of the current match
      Specified by:
      getAverageEntropy in interface Match
      Returns:
      a double representing the average entropy per character of the current Match.
    • getToken

      public String getToken()
      Specified by:
      getToken in interface Match
      Returns:
      the String value of the Match.
    • getStartIndex

      public int getStartIndex()
      Description copied from interface: Match
      Returns the start index of this part of the password
      Specified by:
      getStartIndex in interface Match
      Returns:
      the int start index of this Match.
    • getEndIndex

      public int getEndIndex()
      Description copied from interface: Match
      Returns the end index of this part of the password
      Specified by:
      getEndIndex in interface Match
      Returns:
      the int end index of this Match.
    • getLength

      public int getLength()
      Description copied from interface: Match
      Returns the length of this part of the password
      Specified by:
      getLength in interface Match
      Returns:
      the int length of this Match.
    • getDetails

      public String getDetails()
      Description copied from interface: Match
      Returns details about this match in the form of a String to be printed directly
      Specified by:
      getDetails in interface Match
      Returns:
      all specific details about this Match in printable String format.