Codota Logo
DictionaryGuess.<init>
Code IndexAdd Codota to your IDE (free)

How to use
com.nulabinc.zxcvbn.guesses.DictionaryGuess
constructor

Best Java code snippets using com.nulabinc.zxcvbn.guesses.DictionaryGuess.<init> (Showing top 10 results out of 315)

  • Common ways to obtain DictionaryGuess
private void myMethod () {
DictionaryGuess d =
  • Codota Iconnew DictionaryGuess()
  • Smart code suggestions by Codota
}
origin: com.nulab-inc/zxcvbn

  @Override
  public double exec(Match match) {
    if (match.guesses != null) return match.guesses;
    int minGuesses = 1;
    if (match.token.length() < password.length()) {
      minGuesses = match.token.length() == 1 ? MIN_SUBMATCH_GUESSES_SINGLE_CHAR : MIN_SUBMATCH_GUESSES_MULTI_CHAR;
    }
    final Guess guess;
    switch (match.pattern) {
      case Bruteforce: guess = new BruteforceGuess(); break;
      case Dictionary: guess = new DictionaryGuess(); break;
      case Spatial: guess = new SpatialGuess(); break;
      case Repeat: guess = new RepeatGuess(); break;
      case Sequence: guess = new SequenceGuess(); break;
      case Regex: guess = new RegexGuess(); break;
      case Date: guess = new DateGuess(); break;
      default: guess = null; break;
    }
    double guesses = guess != null ? guess.exec(match) : 0;
    match.guesses = Math.max(guesses, minGuesses);
    match.guessesLog10 = Scoring.log10(match.guesses);
    return  match.guesses;
  }
}
origin: nulab/zxcvbn4j

  @Override
  public double exec(Match match) {
    if (match.guesses != null) return match.guesses;
    int minGuesses = 1;
    if (match.token.length() < password.length()) {
      minGuesses = match.token.length() == 1 ? MIN_SUBMATCH_GUESSES_SINGLE_CHAR : MIN_SUBMATCH_GUESSES_MULTI_CHAR;
    }
    final Guess guess;
    switch (match.pattern) {
      case Bruteforce: guess = new BruteforceGuess(); break;
      case Dictionary: guess = new DictionaryGuess(); break;
      case Spatial: guess = new SpatialGuess(); break;
      case Repeat: guess = new RepeatGuess(); break;
      case Sequence: guess = new SequenceGuess(); break;
      case Regex: guess = new RegexGuess(); break;
      case Date: guess = new DateGuess(); break;
      default: guess = null; break;
    }
    double guesses = guess != null ? guess.exec(match) : 0;
    match.guesses = Math.max(guesses, minGuesses);
    match.guessesLog10 = Scoring.log10(match.guesses);
    return  match.guesses;
  }
}
origin: nulab/zxcvbn4j

@Test
public void testUppercaseVariants() throws Exception {
  DictionaryGuess dictionaryGuess = new DictionaryGuess();
  Method uppercaseVariationsMethod = DictionaryGuess.class.getDeclaredMethod("uppercaseVariations", Match.class);
  uppercaseVariationsMethod.setAccessible(true);
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, word).sub(new HashMap<Character, Character>()).l33t(true).build();
  String msg = String.format("guess multiplier of %s is %s", word, variants);
  assertEquals(msg, variants, uppercaseVariationsMethod.invoke(dictionaryGuess, match));
}
origin: nulab/zxcvbn4j

@Test
public void testDictionaryGuessesMixed() throws Exception {
  Map<Character, Character> sub = new HashMap<>();
  sub.put('@', 'a');
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, "AaA@@@").sub(sub).l33t(true).rank(32).build();
  String msg = "extra guesses are added for both capitalization and common l33t substitutions";
  int expected = 32 * new DictionaryGuess().l33tVariations(match) * new DictionaryGuess().uppercaseVariations(match);
  assertEquals(msg, expected, new DictionaryGuess().exec(match), 0.0);
}
origin: nulab/zxcvbn4j

@Test
public void testDictionaryGuesses133t() throws Exception {
  Map<Character, Character> sub = new HashMap<>();
  sub.put('@', 'a');
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, "aaa@@@").sub(sub).l33t(true).rank(32).build();
  String msg = "extra guesses are added for common l33t substitutions";
  assertEquals(msg, 32 * new DictionaryGuess().l33tVariations(match), new DictionaryGuess().exec(match), 0.0);
}
origin: nulab/zxcvbn4j

@Test
public void testDictionaryGuessesCapitalization() throws Exception {
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, "AAAaaa").rank(32).build();
  String msg = "extra guesses are added for capitalization";
  assertEquals(msg, 32 * new DictionaryGuess().uppercaseVariations(match), new DictionaryGuess().exec(match), 0.0);
}
origin: nulab/zxcvbn4j

  @Test
  public void testL33tVariants() throws Exception {
    Match match = MatchFactory.createDictionaryMatch(0, 0, "", "", 0, "");
    assertEquals("1 variant for non-l33t matches", 1.0, new DictionaryGuess().l33tVariations(match), 0.0);
  }
}
origin: nulab/zxcvbn4j

@Test
public void testL33tVariants() throws Exception {
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, word).sub(sub).l33t(!sub.isEmpty()).build();
  String msg = String.format("extra l33t guesses of %s is %s", word, variants);
  assertEquals(msg, variants, new DictionaryGuess().l33tVariations(match));
}
origin: nulab/zxcvbn4j

@Test
public void testDictionaryGuessesSameWithRank() throws Exception {
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, "aaaa").rank(32).build();
  String msg = "base guesses == the rank";
  assertEquals(msg, 32, new DictionaryGuess().exec(match), 0.0);
}
origin: nulab/zxcvbn4j

@Test
public void testDictionaryGuessesReverse() throws Exception {
  Match match = new Match.Builder(Pattern.Dictionary, 0, 0, "aaa").reversed(true).rank(32).build();
  String msg = "guesses are doubled when word is reversed";
  assertEquals(msg, 32 * 2, new DictionaryGuess().exec(match), 0.0);
}
com.nulabinc.zxcvbn.guessesDictionaryGuess<init>

Popular methods of DictionaryGuess

  • l33tVariations
  • uppercaseVariations
  • nCk
  • exec

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • notifyDataSetChanged (ArrayAdapter)
  • getSupportFragmentManager (FragmentActivity)
    Return the FragmentManager for interacting with fragments associated with this activity.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • PriorityQueue (java.util)
    An unbounded priority Queue based on a priority heap. The elements of the priority queue are ordered
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
  • JList (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now