me.gosimple.nbvcxz.matching.match.BruteForceMatch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nbvcxz Show documentation
Show all versions of nbvcxz Show documentation
Nbvcxz takes heavy inspiration from the zxcvbn library built by Dropbox, and in a lot of ways is
similar.
I built this library to be heavily extensible for every use case, with sane defaults.
package me.gosimple.nbvcxz.matching.match;
import me.gosimple.nbvcxz.resources.BruteForceUtil;
import me.gosimple.nbvcxz.resources.Configuration;
/**
* @author Adam Brusselback
*/
public final class BruteForceMatch extends BaseMatch
{
/**
* Create a new {@code BruteForceMatch}
*
* @param match the {@code String} we are creating the {@code BruteForceMatch} from.
* @param configuration the {@link Configuration} object.
* @param index the index in the password for this match.
*/
public BruteForceMatch(char match, Configuration configuration, int index)
{
super(Character.toString(match), configuration, index, index);
super.setEntropy(getEntropy(match));
}
private double getEntropy(char character)
{
int cardinality = BruteForceUtil.getBrutForceCardinality(character);
return Math.max(0, log2(cardinality * getToken().length()));
}
}