/
Misc.java
62 lines (57 loc) · 1.9 KB
/
Misc.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package net.contra.obfuscator.util.misc;
import net.contra.obfuscator.Settings;
import java.util.Random;
/**
* Created by IntelliJ IDEA.
* User: Contra
* Date: 2/7/11
* Time: 8:36 AM
*/
public class Misc {
public static String getRandomName() {
switch (Settings.ObfuscationLevel) {
case Light:
return getRandomString(5, true);
case Normal:
return getRandomString(8, true);
case Heavy:
return getRandomString(5, false);
case Insane:
return getRandomString(10, false);
default:
return getRandomString(5, true);
}
}
public static String getRandomClassName() {
switch (Settings.ObfuscationLevel) {
case Light:
return getRandomString(8, true);
case Normal:
return getRandomString(10, true);
case Heavy:
return getRandomString(15, true);
case Insane:
return getRandomString(20, true);
default:
return getRandomString(8, true);
}
}
private static String getRandomString(int length, boolean simple) {
if (!simple) {
Random rand = new Random(System.currentTimeMillis());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
sb.append(new char[rand.nextInt(255)]);
}
return sb.toString();
} else {
String charset = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890$_";
Random rand = new Random(System.currentTimeMillis());
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
sb.append(charset.charAt(rand.nextInt(charset.length())));
}
return "c" + sb.toString();
}
}
}