Created
June 16, 2025 02:22
-
-
Save STashakkori/c7bbc36c1496cd066693d80ebba01d6f to your computer and use it in GitHub Desktop.
Generate SSL token in Lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Includes | |
local openssl = require('openssl') | |
local uuid = require('openssl.rand').bytes | |
-- Function to generate a UUID | |
local function generateUUID() | |
local randomBytes = uuid(16) -- 16 bytes of random data | |
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' | |
local d = {} | |
for i = 1, #randomBytes do | |
d[i] = string.format("%02x", string.byte(randomBytes, i)) | |
end | |
local i = 0 | |
return string.gsub(template, '[xy]', function (c) | |
local v = tonumber(d[i + 1] or "0", 16) -- Default to 0 if nil | |
if c == 'x' then | |
v = v | |
elseif c == 'y' then | |
v = (v % 4) + 8 | |
end | |
i = i + 1 | |
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