From: Aaron Smith Date: 2007-03-09T06:44:35+09:00 Subject: generate UUID Anyone have a fast way of generating a verson 4 UUID? I have found some libraries to do this, but it seems like it could be done in about 8 lines of code. Any faster approches? what about this? def rand_hex(l) validChars = ("A".."F").to_a + ("0".."9").to_a length = validChars.size hexCode = "" 1.upto(l) do |i| hexCode << validChars[rand(length-1)] end hexCode end r = "#{rand_hex(8)}-#{rand_hex(4)}-#{rand_hex(4)}-#{rand_hex(4)}-#{rand_hex(12)}" puts r thanks -- Posted via http://www.ruby-forum.com/.