Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local UUIDGenerator = {}
- function UUIDGenerator:Generate(dashes: boolean?)
- dashes = (type(dashes) ~= "boolean") and true or dashes
- local uuid = ""
- local length = 32
- for i = 1, length/4 do
- for i_ = 1, math.random(2, 4) do
- local hex = math.random(0, 255)
- hex = ("%x"):format(hex)
- uuid = uuid..hex
- end
- if dashes then
- if i == length/4 then
- continue
- end
- uuid = uuid.."-"
- end
- end
- return uuid:sub(1, length)
- end
- return UUIDGenerator
Advertisement
Add Comment
Please, Sign In to add comment