Skip to content

Commit

Permalink
Merge pull request #150 from nulab/apply-google-java-format
Browse files Browse the repository at this point in the history
style: format all with google-java-format
  • Loading branch information
vvatanabe authored Aug 19, 2023
2 parents a90235c + 0347d6e commit a213a44
Show file tree
Hide file tree
Showing 52 changed files with 3,527 additions and 3,291 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
id 'com.github.kt3k.coveralls' version '2.12.0'
id "me.champeau.jmh" version "0.6.6"
id "com.github.spotbugs" version "5.1.2"
id 'com.github.sherter.google-java-format' version '0.9'
}

group = 'com.nulab-inc'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.nulabinc.zxcvbn;

import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
Expand All @@ -12,10 +15,6 @@
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

import java.io.IOException;
import java.util.Random;
import java.util.concurrent.TimeUnit;

@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Thread)
Expand All @@ -24,29 +23,31 @@
@Fork(1)
public class RandomPasswordMeasureBenchmark {

@Param({"8", "32", "128", "512", "1024"})
private int passwordLength;
private String password;
Zxcvbn zxcvbn;
@Param({"8", "32", "128", "512", "1024"})
private int passwordLength;

@Setup
public void setup() throws IOException {
zxcvbn = new ZxcvbnBuilder()
.dictionaries(StandardDictionaries.loadAllDictionaries())
.keyboards(StandardKeyboards.loadAllKeyboards())
.build();
private String password;
Zxcvbn zxcvbn;

Random random = new Random(42);
StringBuilder sb = new StringBuilder(passwordLength);
for (int i = 0; i < passwordLength; i++) {
char c = (char) (random.nextInt() % Character.MAX_VALUE);
sb.append(c);
}
password = sb.toString();
}
@Setup
public void setup() throws IOException {
zxcvbn =
new ZxcvbnBuilder()
.dictionaries(StandardDictionaries.loadAllDictionaries())
.keyboards(StandardKeyboards.loadAllKeyboards())
.build();

@Benchmark
public Strength measure() {
return zxcvbn.measure(password);
Random random = new Random(42);
StringBuilder sb = new StringBuilder(passwordLength);
for (int i = 0; i < passwordLength; i++) {
char c = (char) (random.nextInt() % Character.MAX_VALUE);
sb.append(c);
}
}
password = sb.toString();
}

@Benchmark
public Strength measure() {
return zxcvbn.measure(password);
}
}
222 changes: 111 additions & 111 deletions src/main/java/com/nulabinc/zxcvbn/AttackTimes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,138 +2,138 @@

public class AttackTimes {

private CrackTimeSeconds crackTimeSeconds;
private CrackTimesDisplay crackTimesDisplay;
private int score;

public AttackTimes(CrackTimeSeconds crackTimeSeconds, CrackTimesDisplay crackTimesDisplay, int score) {
this.crackTimeSeconds = crackTimeSeconds;
this.crackTimesDisplay = crackTimesDisplay;
this.score = score;
private CrackTimeSeconds crackTimeSeconds;
private CrackTimesDisplay crackTimesDisplay;
private int score;

public AttackTimes(
CrackTimeSeconds crackTimeSeconds, CrackTimesDisplay crackTimesDisplay, int score) {
this.crackTimeSeconds = crackTimeSeconds;
this.crackTimesDisplay = crackTimesDisplay;
this.score = score;
}

public CrackTimeSeconds getCrackTimeSeconds() {
return crackTimeSeconds;
}

public void setCrackTimeSeconds(CrackTimeSeconds crackTimeSeconds) {
this.crackTimeSeconds = crackTimeSeconds;
}

public CrackTimesDisplay getCrackTimesDisplay() {
return crackTimesDisplay;
}

public void setCrackTimesDisplay(CrackTimesDisplay crackTimesDisplay) {
this.crackTimesDisplay = crackTimesDisplay;
}

public int getScore() {
return score;
}

public void setScore(int score) {
this.score = score;
}

public static class CrackTimeSeconds {
private double onlineThrottling100perHour;
private double onlineNoThrottling10perSecond;
private double offlineSlowHashing1e4perSecond;
private double offlineFastHashing1e10PerSecond;

public CrackTimeSeconds(
double onlineThrottling100perHour,
double onlineNoThrottling10perSecond,
double offlineSlowHashing1e4perSecond,
double offlineFastHashing1e10PerSecond) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}

public CrackTimeSeconds getCrackTimeSeconds() {
return crackTimeSeconds;
public double getOnlineThrottling100perHour() {
return onlineThrottling100perHour;
}

public void setCrackTimeSeconds(CrackTimeSeconds crackTimeSeconds) {
this.crackTimeSeconds = crackTimeSeconds;
public void setOnlineThrottling100perHour(double onlineThrottling100perHour) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
}

public CrackTimesDisplay getCrackTimesDisplay() {
return crackTimesDisplay;
public double getOnlineNoThrottling10perSecond() {
return onlineNoThrottling10perSecond;
}

public void setCrackTimesDisplay(CrackTimesDisplay crackTimesDisplay) {
this.crackTimesDisplay = crackTimesDisplay;
public void setOnlineNoThrottling10perSecond(double onlineNoThrottling10perSecond) {
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
}

public int getScore() {
return score;
public double getOfflineSlowHashing1e4perSecond() {
return offlineSlowHashing1e4perSecond;
}

public void setScore(int score) {
this.score = score;
public void setOfflineSlowHashing1e4perSecond(double offlineSlowHashing1e4perSecond) {
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
}

public static class CrackTimeSeconds {
private double onlineThrottling100perHour;
private double onlineNoThrottling10perSecond;
private double offlineSlowHashing1e4perSecond;
private double offlineFastHashing1e10PerSecond;

public CrackTimeSeconds(
double onlineThrottling100perHour,
double onlineNoThrottling10perSecond,
double offlineSlowHashing1e4perSecond,
double offlineFastHashing1e10PerSecond) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}

public double getOnlineThrottling100perHour() {
return onlineThrottling100perHour;
}

public void setOnlineThrottling100perHour(double onlineThrottling100perHour) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
}

public double getOnlineNoThrottling10perSecond() {
return onlineNoThrottling10perSecond;
}

public void setOnlineNoThrottling10perSecond(double onlineNoThrottling10perSecond) {
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
}

public double getOfflineSlowHashing1e4perSecond() {
return offlineSlowHashing1e4perSecond;
}

public void setOfflineSlowHashing1e4perSecond(double offlineSlowHashing1e4perSecond) {
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
}

public double getOfflineFastHashing1e10PerSecond() {
return offlineFastHashing1e10PerSecond;
}

public void setOfflineFastHashing1e10PerSecond(double offlineFastHashing1e10PerSecond) {
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}
public double getOfflineFastHashing1e10PerSecond() {
return offlineFastHashing1e10PerSecond;
}

public static class CrackTimesDisplay {
private String onlineThrottling100perHour;
private String onlineNoThrottling10perSecond;
private String offlineSlowHashing1e4perSecond;
private String offlineFastHashing1e10PerSecond;

public CrackTimesDisplay(
String onlineThrottling100perHour,
String onlineNoThrottling10perSecond,
String offlineSlowHashing1e4perSecond,
String offlineFastHashing1e10PerSecond) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}
public void setOfflineFastHashing1e10PerSecond(double offlineFastHashing1e10PerSecond) {
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}
}

public static class CrackTimesDisplay {
private String onlineThrottling100perHour;
private String onlineNoThrottling10perSecond;
private String offlineSlowHashing1e4perSecond;
private String offlineFastHashing1e10PerSecond;

public CrackTimesDisplay(
String onlineThrottling100perHour,
String onlineNoThrottling10perSecond,
String offlineSlowHashing1e4perSecond,
String offlineFastHashing1e10PerSecond) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}

public String getOnlineThrottling100perHour() {
return onlineThrottling100perHour;
}
public String getOnlineThrottling100perHour() {
return onlineThrottling100perHour;
}

public void setOnlineThrottling100perHour(String onlineThrottling100perHour) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
}
public void setOnlineThrottling100perHour(String onlineThrottling100perHour) {
this.onlineThrottling100perHour = onlineThrottling100perHour;
}

public String getOnlineNoThrottling10perSecond() {
return onlineNoThrottling10perSecond;
}
public String getOnlineNoThrottling10perSecond() {
return onlineNoThrottling10perSecond;
}

public void setOnlineNoThrottling10perSecond(String onlineNoThrottling10perSecond) {
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
}
public void setOnlineNoThrottling10perSecond(String onlineNoThrottling10perSecond) {
this.onlineNoThrottling10perSecond = onlineNoThrottling10perSecond;
}

public String getOfflineSlowHashing1e4perSecond() {
return offlineSlowHashing1e4perSecond;
}
public String getOfflineSlowHashing1e4perSecond() {
return offlineSlowHashing1e4perSecond;
}

public void setOfflineSlowHashing1e4perSecond(String offlineSlowHashing1e4perSecond) {
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
}
public void setOfflineSlowHashing1e4perSecond(String offlineSlowHashing1e4perSecond) {
this.offlineSlowHashing1e4perSecond = offlineSlowHashing1e4perSecond;
}

public String getOfflineFastHashing1e10PerSecond() {
return offlineFastHashing1e10PerSecond;
}
public String getOfflineFastHashing1e10PerSecond() {
return offlineFastHashing1e10PerSecond;
}

public void setOfflineFastHashing1e10PerSecond(String offlineFastHashing1e10PerSecond) {
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}
}

}
public void setOfflineFastHashing1e10PerSecond(String offlineFastHashing1e10PerSecond) {
this.offlineFastHashing1e10PerSecond = offlineFastHashing1e10PerSecond;
}
}
}
27 changes: 13 additions & 14 deletions src/main/java/com/nulabinc/zxcvbn/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@

import com.nulabinc.zxcvbn.matchers.Dictionary;
import com.nulabinc.zxcvbn.matchers.Keyboard;

import java.util.Collections;
import java.util.Map;

public class Context {

private final Map<String, Dictionary> dictionaryMap;

private final Map<String, Keyboard> keyboardMap;
private final Map<String, Dictionary> dictionaryMap;

public Context(final Map<String, Dictionary> dictionaryMap, final Map<String, Keyboard> keyboardMap) {
this.dictionaryMap = dictionaryMap;
this.keyboardMap = keyboardMap;
}
private final Map<String, Keyboard> keyboardMap;

public Map<String, Dictionary> getDictionaryMap() {
return Collections.unmodifiableMap(this.dictionaryMap);
}
public Context(
final Map<String, Dictionary> dictionaryMap, final Map<String, Keyboard> keyboardMap) {
this.dictionaryMap = dictionaryMap;
this.keyboardMap = keyboardMap;
}

public Map<String, Keyboard> getKeyboardMap() {
return Collections.unmodifiableMap(this.keyboardMap);
}
public Map<String, Dictionary> getDictionaryMap() {
return Collections.unmodifiableMap(this.dictionaryMap);
}

public Map<String, Keyboard> getKeyboardMap() {
return Collections.unmodifiableMap(this.keyboardMap);
}
}
Loading

0 comments on commit a213a44

Please sign in to comment.