[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Uniqid(php) for ruby:

Tannev Vitaliy

6/17/2008 11:31:00 AM

Php code:

$uniq_id = md5(uniqid(time()));


As for ruby?:(

thanks.
--
Posted via http://www.ruby-....

2 Answers

Dave Bass

6/17/2008 1:48:00 PM

0

Tannev Vitaliy wrote:
> $uniq_id = md5(uniqid(time()));

Coming from Perl, I use a combination of the system time and the process
ID as the basis for a unique ID. I don't know if Ruby has anything
ready-made for this, but it would be nice if it did.

MD5 and other hashing algorithms are susceptible to collisions, so you
won't necessarily get a unique ID even if the original data is unique.

--
Posted via http://www.ruby-....

Hassan Schroeder

6/17/2008 2:14:00 PM

0

On Tue, Jun 17, 2008 at 4:31 AM, Tannev Vitaliy <444ert666@gmail.com> wrote:

> As for ruby?:(

prompt% gem list --remote --no-update-sources | grep uuid
uuid (1.0.4)
uuid4r (0.1)
uuidtools (1.0.3)

HTH!
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com