Skip to content

Instantly share code, notes, and snippets.

View webr0m's full-sized avatar

Webrom webr0m

View GitHub Profile
@haggen
haggen / string.random.lua
Last active July 24, 2026 18:00
Random strings in Lua
math.randomseed(os.time())
local charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
function string.random(length)
if length > 0 then
return string.random(length - 1) .. charset:sub(math.random(1, #charset), 1)
else
return ""
end