tags:

views:

443

answers:

2

I have problem that is really easily solved with Guids.

In particular, for a password reset workflow I would like to send a Guid token to a users email and have them reset their password using the token. Since guids are unique this is pretty secure and saves me emailing people passwords which is risky.

I noticed there is one Guid gem for Ruby but it looks quite old and it writes stuff to the file system.

Does anyone know of any other gems that can create a globally unique identifier?

I know I can just fall back to:

(0..16).to_a.map{|a| rand(16).to_s(16)}.join

But it does not really seem like a proper GUID ...

+6  A: 

Did you look at UUIDTools?

UUIDTools was designed to be a simple library for generating any of the various types of UUIDs (or GUIDs if you prefer to call them that). It conforms to RFC 4122 whenever possible.

Andrew Hare
nope did not notice that. It looks like it solves my problem
Sam Saffron
Very cool - I hope it does the trick :)
Andrew Hare