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 java.lang.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 Configuration configuration  
    protected static double LOG_10  
    protected static double LOG_129  
    protected static double LOG_2  
    protected static double LOG_26  
    protected static double LOG_37200  
    protected static double LOG_47988  
  • Constructor Summary

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

    Modifier and Type Method Description
    double calculateEntropy()
    Calculate the entropy for the current match
    double getAverageEntropy()
    Get the average entropy per character of the current match
    java.lang.String getDetails()
    Returns details about this match in the form of a String to be printed directly
    int getEndIndex()
    Returns the end index of this part of the password
    int getLength()
    Returns the length of this part of the password
    int getStartIndex()
    Returns the start index of this part of the password
    java.lang.String getToken()  
    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​(java.lang.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 java.lang.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 java.lang.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.