2016-01-05 04:20:40 +11:00
|
|
|
local random = {}
|
|
|
|
|
|
|
|
function random.uuid()
|
|
|
|
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
|
|
|
return string.gsub(template, '[xy]', function (c)
|
2016-01-07 02:58:05 +11:00
|
|
|
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
|
2016-01-05 04:20:40 +11:00
|
|
|
return string.format('%x', v)
|
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
return random
|