Skip to content

Commit 639b425

Browse files
committed
make my own UUID
1 parent 85a7e6d commit 639b425

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/net/sharksystem/asap/ASAP.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public static String createUniqueID() {
4848
*/
4949

5050
char[] idChars = new char[digits];
51-
// init
51+
// init with random number
5252
for(int i = 0; i < digits; i++) idChars[i] = '0';
5353

54-
// let's fill it
54+
// let's fill it with code time stamp
5555
int i = 0;
5656
long rest = 0;
5757
while(now > 0) {
@@ -62,16 +62,20 @@ public static String createUniqueID() {
6262
}
6363

6464
// set index
65-
i = timeDigits;
65+
//i = timeDigits;
6666

6767
// random digits
6868
long rValue = now + nowUnchanged;
6969
Random random = new Random(rValue);
70-
for(int j = 0; j < randomDigits; j++) {
70+
//char lastC = ' '; // not value space
71+
while(i < digits) {
7172
int r = random.nextInt(basis);
72-
idChars[i++] = ASAP.int2charID(r);
73-
rValue = (rValue * r) % basis;
74-
random.setSeed(rValue);
73+
char c = ASAP.int2charID(r);
74+
//if(c == lastC) continue;
75+
idChars[i++] = c;
76+
rValue = (rValue * r * nowUnchanged) % basis;
77+
random = new Random(rValue);
78+
//random.setSeed(rValue);
7579
}
7680

7781
return new String(idChars);

0 commit comments

Comments
 (0)