
TomS_
New User
Dec 30, 2008, 3:01 AM
Post #2 of 2
(704 views)
|
|
Re: [srikrishnan] How to generate UUID for DocumentID and InstanceID
[In reply to]
|
Can't Post
|
|
Well, technically speaking, you should never be able to generate the same UUID or GUID twice. They are meant to be different such that they can be relied upon to be (reasonably) unique (what ever the probability is of generating the same sequence of 128 bits is). But IIRC UUIDs arent entirely random, they are based on time, aswell as some randomness. This means that you should never see the same UUID twice, because time is always increasing and seconds of time rarely repeat. Unless I dont understand your question correctly, I dont see what is so difficult? I whipped this script up in about two minutes (including the time taken to install Data::UUID from CPAN):
#!/usr/local/bin/perl use strict; use Data::UUID; my $ug = new Data::UUID; my $uuid = $ug->create(); print "\n" . $ug->to_string($uuid) . "\n\n"; 1; Running the script gives me:
[building 21:28]/home/tom/perl> ./uuid D70CE142-D660-11DD-B94C-C6F8E2A78DDD [building 21:28]/home/tom/perl> ./uuid D906E52E-D660-11DD-9926-C7F8E2A78DDD [building 21:28]/home/tom/perl> ./uuid DAB20908-D660-11DD-8333-C8F8E2A78DDD [building 21:28]/home/tom/perl> ./uuid DB7E2ABA-D660-11DD-8B6B-C9F8E2A78DDD [building 21:28]/home/tom/perl> ./uuid DC1BBBF4-D660-11DD-8388-CAF8E2A78DDD Pretty simple it seems? Hope that helps you. :-) Tom
(This post was edited by TomS_ on Dec 30, 2008, 3:08 AM)
|