public static String displayTime(final double seconds) { final Double minute = 60.0; final Double hour = minute * 60; final Double day = hour * 24; final Double month = day * 31; final Double year = month * 12; final Double century = year * 100; if (seconds < 1) return format(null, "less than a second"); else if (seconds < minute) return format(seconds, "%s second"); else if (seconds < hour) return format(divide(seconds, minute), "%s minute"); else if (seconds < day) return format(divide(seconds, hour), "%s hour"); else if (seconds < month) return format(divide(seconds, day), "%s day"); else if (seconds < year) return format(divide(seconds, month), "%s month"); else if (seconds < century) return format(divide(seconds, year), "%s year"); else return format(null, "centuries"); }
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, List<String> sanitizedInputs) { if (password == null) { throw new IllegalArgumentException("Password is null."); } List<String> lowerSanitizedInputs; if (sanitizedInputs != null && !sanitizedInputs.isEmpty()) { lowerSanitizedInputs = new ArrayList<>(sanitizedInputs.size()); for (String sanitizedInput : sanitizedInputs) { lowerSanitizedInputs.add(sanitizedInput.toLowerCase()); } } else { lowerSanitizedInputs = Collections.emptyList(); } long start = time(); Matching matching = createMatching(lowerSanitizedInputs); List<Match> matches = matching.omnimatch(password); Strength strength = Scoring.mostGuessableMatchSequence(password, matches); strength.setCalcTime(time() - start); AttackTimes attackTimes = TimeEstimates.estimateAttackTimes(strength.getGuesses()); strength.setCrackTimeSeconds(attackTimes.getCrackTimeSeconds()); strength.setCrackTimesDisplay(attackTimes.getCrackTimesDisplay()); strength.setScore(attackTimes.getScore()); strength.setFeedback(Feedback.getFeedback(strength.getScore(), strength.getSequence())); return strength; }
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, List<String> sanitizedInputs) { if (password == null) { throw new IllegalArgumentException("Password is null."); } List<String> lowerSanitizedInputs; if (sanitizedInputs != null && !sanitizedInputs.isEmpty()) { lowerSanitizedInputs = new ArrayList<>(sanitizedInputs.size()); for (String sanitizedInput : sanitizedInputs) { lowerSanitizedInputs.add(sanitizedInput.toLowerCase()); } } else { lowerSanitizedInputs = Collections.emptyList(); } long start = time(); Matching matching = createMatching(lowerSanitizedInputs); List<Match> matches = matching.omnimatch(password); Strength strength = Scoring.mostGuessableMatchSequence(password, matches); strength.setCalcTime(time() - start); AttackTimes attackTimes = TimeEstimates.estimateAttackTimes(strength.getGuesses()); strength.setCrackTimeSeconds(attackTimes.getCrackTimeSeconds()); strength.setCrackTimesDisplay(attackTimes.getCrackTimesDisplay()); strength.setScore(attackTimes.getScore()); strength.setFeedback(Feedback.getFeedback(strength.getScore(), strength.getSequence())); return strength; }
public static String displayTime(final double seconds) { final Double minute = 60.0; final Double hour = minute * 60; final Double day = hour * 24; final Double month = day * 31; final Double year = month * 12; final Double century = year * 100; if (seconds < 1) return format(null, "less than a second"); else if (seconds < minute) return format(seconds, "%s second"); else if (seconds < hour) return format(divide(seconds, minute), "%s minute"); else if (seconds < day) return format(divide(seconds, hour), "%s hour"); else if (seconds < month) return format(divide(seconds, day), "%s day"); else if (seconds < year) return format(divide(seconds, month), "%s month"); else if (seconds < century) return format(divide(seconds, year), "%s year"); else return format(null, "centuries"); }