GUIDGenerator.java
2.48 KB
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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.aemfd.watchfolder.job;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Random;
public class GUIDGenerator {
public static final int GUID_LENGTH = 26;
private static final byte[] GUID_OBFUSCATION_MASK = new byte[]{-28, 124, -14, 61, 11, -87, 88, 37, -63, -101, -113, 48};
private static final char[] GUID_DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
private static int s_guidCount = new Random(System.currentTimeMillis()).nextInt();
private static int s_guidAddress;
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public static String generate(char prefix) {
StringBuffer buffer = new StringBuffer();
byte[] guid = new byte[12];
Class<GUIDGenerator> class_ = GUIDGenerator.class;
synchronized (GUIDGenerator.class) {
if (s_guidAddress == 0) {
try {
s_guidAddress = InetAddress.getLocalHost().hashCode();
}
catch (UnknownHostException exception) {
s_guidAddress = Thread.currentThread().hashCode();
}
}
// ** MonitorExit[var5_3] (shouldn't be in output)
long time = System.currentTimeMillis();
guid[0] = (byte)((++s_guidCount & 65280) >> 8);
guid[1] = (byte)((s_guidAddress & -16777216) >> 24);
guid[2] = (byte)((time & 0xFF0000) >> 16);
guid[3] = (byte)(s_guidCount & 255);
guid[4] = (byte)((time & -16777216) >> 24);
guid[5] = (byte)((s_guidAddress & 65280) >> 8);
guid[6] = (byte)((s_guidCount & -16777216) >> 24);
guid[7] = (byte)(time & 255);
guid[8] = (byte)(s_guidAddress & 255);
guid[9] = (byte)((s_guidCount & 16711680) >> 16);
guid[10] = (byte)((s_guidAddress & 16711680) >> 16);
guid[11] = (byte)((time & 65280) >> 8);
buffer.append(prefix);
buffer.append('x');
for (int index = 0; index < 12; ++index) {
byte[] arrby = guid;
int n = index;
arrby[n] = (byte)(arrby[n] ^ GUID_OBFUSCATION_MASK[index]);
buffer.append(GUID_DIGITS[guid[index] & 15]);
buffer.append(GUID_DIGITS[(guid[index] & 240) >> 4]);
}
return buffer.toString();
}
}
}