File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes crc32 and VMID for unique names Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "crc32 and VMID for unique names" Watch "crc32 and VMID for unique names" New topic
Author

crc32 and VMID for unique names

Stephanie Smith
Greenhorn

Joined: Jun 28, 2001
Posts: 22
I want to generate unique names.
The VMID object is unique within a jvm.
I create the VMID, and then pass the bytes into CRC32 and convert to hex string.

Should this generated hex string be unique within like 100,000 iterations of creating a name? how likely are duplicates?
I have tested it with over 700K iterations (of creating VMID, passing into CRC32 and converting to hex string) with no duplicates but wanted to know if duplicates were possible.

Thanks for any advice.
Ladislav Honsa
Greenhorn

Joined: Jun 15, 2008
Posts: 5
Hello,

What do you want to use the unique names for? How many unique names do you need to generate?
I would probably use the java.util.UUID class instead. An UUID is 128 bit (i.e. 10^38) long. Of course, you can get duplicates. However it is VERY unlikely. See this link:
http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates

Ladislav
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: crc32 and VMID for unique names
 
Similar Threads
Reliability of using the VMID as a seed for SecureRandom in generating GUID's
Right bit Shift Operator In Java
please hint me on "SortNames" !
Problem of inserting java array into DB
CRC algorithm