[FIX] Генерация словаря учитывает размер projectName

This commit is contained in:
Gravit 2019-09-05 19:37:46 +07:00
parent dbc7fa36e7
commit cf18ce6110
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -19,11 +19,12 @@ public class ProguardConf {
private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ"; private static final String chars = "1aAbBcC2dDeEfF3gGhHiI4jJkKl5mMnNoO6pPqQrR7sStT8uUvV9wWxX0yYzZ";
private static String generateString(SecureRandom rand, String lowString, String upString, int il) { private static String generateString(SecureRandom rand, String lowString, String upString, int il) {
StringBuilder sb = new StringBuilder(il + lowString.length()); StringBuilder sb = new StringBuilder(Math.max(il, lowString.length()));
for (int i = 0; i < lowString.length(); ++i) { for (int i = 0; i < lowString.length(); ++i) {
sb.append(rand.nextBoolean() ? lowString.charAt(i) : upString.charAt(i)); sb.append(rand.nextBoolean() ? lowString.charAt(i) : upString.charAt(i));
} }
for (int i = 0; i < il - 1; i++) sb.append(chars.charAt(rand.nextInt(chars.length()))); int toI = il - lowString.length();
for (int i = 0; i < toI; i++) sb.append(chars.charAt(rand.nextInt(chars.length())));
return sb.toString(); return sb.toString();
} }
@ -74,7 +75,7 @@ public void genWords(boolean force) throws IOException {
String projectName = srv.config.projectName.replaceAll("\\W", ""); String projectName = srv.config.projectName.replaceAll("\\W", "");
String lowName = projectName.toLowerCase(); String lowName = projectName.toLowerCase();
String upName = projectName.toUpperCase(); String upName = projectName.toUpperCase();
for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 3)); for (int i = 0; i < Short.MAX_VALUE; i++) out.println(generateString(rand, lowName, upName, 14));
} }
} }