Skip to content

Instantly share code, notes, and snippets.

@jaybaird
Forked from jrus/lua-uuid.lua
Last active October 24, 2015 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jaybaird/c99c1dc3a88a1acdd66c to your computer and use it in GitHub Desktop.
Save jaybaird/c99c1dc3a88a1acdd66c to your computer and use it in GitHub Desktop.
local random = math.random
local function uuid()
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function (c)
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
return string.format('%x', v)
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment