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 Configurationconfigurationprotected static doubleLOG_10protected static doubleLOG_129protected static doubleLOG_2protected static doubleLOG_26protected static doubleLOG_37200protected static doubleLOG_47988 -
Constructor Summary
Constructors Constructor Description BaseMatch(java.lang.String match, Configuration configuration, int start_index, int end_index)Create a newBaseMatch -
Method Summary
Modifier and Type Method Description doublecalculateEntropy()Calculate the entropy for the current matchdoublegetAverageEntropy()Get the average entropy per character of the current matchjava.lang.StringgetDetails()Returns details about this match in the form of a String to be printed directlyintgetEndIndex()Returns the end index of this part of the passwordintgetLength()Returns the length of this part of the passwordintgetStartIndex()Returns the start index of this part of the passwordjava.lang.StringgetToken()protected static doublelog2(double value)Calculate the base 2 logarithm of a valueprotected static longnCk(int n, int k)Calculate binomial coefficients (the number of possible "choose k among n")protected voidsetEntropy(double entropy)
-
Field Details
-
Constructor Details
-
BaseMatch
public BaseMatch(java.lang.String match, Configuration configuration, int start_index, int end_index)Create a newBaseMatch- Parameters:
match- theStringwe are creating theBaseMatchfrom.configuration- theConfigurationobject.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- thedoublewe 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 setk- the size of the selection- Returns:
- the binomial coefficient
-
setEntropy
protected void setEntropy(double entropy) -
calculateEntropy
public final double calculateEntropy()Description copied from interface:MatchCalculate the entropy for the current match- Specified by:
calculateEntropyin interfaceMatch- Returns:
- a
doublerepresenting the entropy of the currentMatch.
-
getAverageEntropy
public double getAverageEntropy()Description copied from interface:MatchGet the average entropy per character of the current match- Specified by:
getAverageEntropyin interfaceMatch- Returns:
- a
doublerepresenting the average entropy per character of the currentMatch.
-
getToken
public java.lang.String getToken() -
getStartIndex
public int getStartIndex()Description copied from interface:MatchReturns the start index of this part of the password- Specified by:
getStartIndexin interfaceMatch- Returns:
- the
intstart index of thisMatch.
-
getEndIndex
public int getEndIndex()Description copied from interface:MatchReturns the end index of this part of the password- Specified by:
getEndIndexin interfaceMatch- Returns:
- the
intend index of thisMatch.
-
getLength
public int getLength()Description copied from interface:MatchReturns the length of this part of the password -
getDetails
public java.lang.String getDetails()Description copied from interface:MatchReturns details about this match in the form of a String to be printed directly- Specified by:
getDetailsin interfaceMatch- Returns:
- all specific details about this
Matchin printable String format.
-