public static AttackTimes estimateAttackTimes(double guesses) { AttackTimes.CrackTimeSeconds crackTimeSeconds = new AttackTimes.CrackTimeSeconds( divide(guesses, 100.0 / 3600.0), guesses / 10, guesses / 1e4, guesses / 1e10 ); AttackTimes.CrackTimesDisplay crackTimesDisplay = new AttackTimes.CrackTimesDisplay( displayTime(crackTimeSeconds.getOnlineThrottling100perHour()), displayTime(crackTimeSeconds.getOnlineNoThrottling10perSecond()), displayTime(crackTimeSeconds.getOfflineSlowHashing1e4perSecond()), displayTime(crackTimeSeconds.getOfflineFastHashing1e10PerSecond()) ); return new AttackTimes(crackTimeSeconds, crackTimesDisplay, guessesToScore(guesses)); }
public String getWarning(Locale locale) { if (this.warning == null) { return ""; } ResourceBundle messages = resolveResourceBundle(locale); return l10n(messages, this.warning); }
private static Feedback getFeedbackWithoutWarnings(String... suggestions) { return new Feedback(null, suggestions); }
@Test public void testUnknownWarning() { Zxcvbn zxcvbn = new Zxcvbn(); Strength strength = zxcvbn.measure(password); Feedback feedback = strength.getFeedback().withResourceBundle(null); Assert.assertEquals("Unexpected warning", expectedWarning, feedback.getWarning()); }
@Test public void testUnknownSuggestions() { Zxcvbn zxcvbn = new Zxcvbn(); Strength strength = zxcvbn.measure(password); Feedback feedback = strength.getFeedback().withResourceBundle(null); Assert.assertArrayEquals("Unexpected suggestions", expectedSuggestions, feedback.getSuggestions().toArray()); }
@Test public void testMeasure() throws Exception { Zxcvbn zxcvbn = new Zxcvbn(); Strength strength = zxcvbn.measure(password); assertEquals("Unexpected error. Password is " + password, password, strength.getPassword()); }
public Strength measure(String password) { return measure(password, null); }
public static Strength mostGuessableMatchSequence(String password, List<Match> matches) { return mostGuessableMatchSequence(password, matches, false); }
protected Matching createMatching(List<String> lowerSanitizedInputs) { return new Matching(lowerSanitizedInputs); }
public Feedback withResourceBundle(ResourceBundle messages) { return new ResourceBundleFeedback(messages, warning, suggestions); }
public JavaPortTest(String password) { this.password = password; zxcvbn = new Zxcvbn(); }
public static AttackTimes estimateAttackTimes(double guesses) { AttackTimes.CrackTimeSeconds crackTimeSeconds = new AttackTimes.CrackTimeSeconds( divide(guesses, 100.0 / 3600.0), guesses / 10, guesses / 1e4, guesses / 1e10 ); AttackTimes.CrackTimesDisplay crackTimesDisplay = new AttackTimes.CrackTimesDisplay( displayTime(crackTimeSeconds.getOnlineThrottling100perHour()), displayTime(crackTimeSeconds.getOnlineNoThrottling10perSecond()), displayTime(crackTimeSeconds.getOfflineSlowHashing1e4perSecond()), displayTime(crackTimeSeconds.getOfflineFastHashing1e10PerSecond()) ); return new AttackTimes(crackTimeSeconds, crackTimesDisplay, guessesToScore(guesses)); }
public Strength measure(String password) { return measure(password, null); }
public String getWarning(Locale locale) { if (this.warning == null) { return ""; } ResourceBundle messages = resolveResourceBundle(locale); return l10n(messages, this.warning); }
public static Strength mostGuessableMatchSequence(String password, List<Match> matches) { return mostGuessableMatchSequence(password, matches, false); }
protected Matching createMatching(List<String> lowerSanitizedInputs) { return new Matching(lowerSanitizedInputs); }
private static Feedback getEmptyFeedback() { return new Feedback(null); }
public Feedback withResourceBundle(ResourceBundle messages) { return new ResourceBundleFeedback(messages, warning, suggestions); }
private static Feedback getEmptyFeedback() { return new Feedback(null); }
private static Feedback getFeedbackWithoutWarnings(String... suggestions) { return new Feedback(null, suggestions); }