private static String createInsecureUUID() { StringBuffer s = new StringBuffer(36); appendHexString(uniqueTOD(), false, 11, s); // Just use random padding characters, but ensure that the high bit // is set to eliminate chances of collision with an IEEE 802 address. s.append( alphaNum.charAt( _weakRand.nextInt(16) | 8 ) ); // Add random padding characters. appendRandomHexChars(32 - s.length(), _weakRand, s); //insert dashes in proper position. so the format matches CF s.insert(8,"-"); s.insert(13,"-"); s.insert(18,"-"); s.insert(23,"-"); return s.toString(); }
private static String createInsecureUUID() { StringBuffer s = new StringBuffer(36); appendHexString(uniqueTOD(), false, 11, s); // Just use random padding characters, but ensure that the high bit // is set to eliminate chances of collision with an IEEE 802 address. s.append( alphaNum.charAt( _weakRand.nextInt(16) | 8 ) ); // Add random padding characters. appendRandomHexChars(32 - s.length(), _weakRand, s); //insert dashes in proper position. so the format matches CF s.insert(8,"-"); s.insert(13,"-"); s.insert(18,"-"); s.insert(23,"-"); return s.toString(); }
/** * @param secure Boolean indicating whether to create a secure UUID. * @see #createUUID() */ public static String createUUID(boolean secure) { Random rand = secure ? _rand : _weakRand; StringBuffer s = new StringBuffer(36); appendHexString(uniqueTOD(), false, 11, s); // Just use random padding characters, but ensure that the high bit // is set to eliminate chances of collision with an IEEE 802 address. s.append( alphaNum.charAt( rand.nextInt(16) | 8 ) ); // Add random padding characters. appendRandomHexChars(32 - s.length(), rand, s); //insert dashes in proper position. so the format matches CF s.insert(8,"-"); s.insert(13,"-"); s.insert(18,"-"); s.insert(23,"-"); return s.toString(); }
public static String createUUID(boolean secure) throws Error { Random rand = _weakRand; if (secure) throw new Error("Secure UUIDs not implemented"); StringBuffer s = new StringBuffer(36); appendHexString(uniqueTOD(), false, 11, s); // Just use random padding characters, but ensure that the high bit // is set to eliminate chances of collision with an IEEE 802 address. s.append( alphaNum.charAt( rand.nextInt(16) | 8 ) ); // Add random padding characters. appendRandomHexChars(32 - s.length(), rand, s); //insert dashes in proper position. so the format matches CF s.insert(8,"-"); s.insert(13,"-"); s.insert(18,"-"); s.insert(23,"-"); return s.toString(); }
public static String createUUID(boolean secure) throws Error { Random rand = _weakRand; if (secure) throw new Error("Secure UUIDs not implemented"); StringBuffer s = new StringBuffer(36); appendHexString(uniqueTOD(), false, 11, s); // Just use random padding characters, but ensure that the high bit // is set to eliminate chances of collision with an IEEE 802 address. s.append( alphaNum.charAt( rand.nextInt(16) | 8 ) ); // Add random padding characters. appendRandomHexChars(32 - s.length(), rand, s); //insert dashes in proper position. so the format matches CF s.insert(8,"-"); s.insert(13,"-"); s.insert(18,"-"); s.insert(23,"-"); return s.toString(); }