Quick actions

cmd+k|ctrl+k

Navigation

Languages

Random hexadecimal generator

Snippet info

Language

Lua

Visibility

public

Author

furryboy

Created

2025-05-04T06:22:44.659531Z

Updated

2025-12-07T22:28:22.117151Z

local length = 64
local how_many = 5
local uppercase = false
local useSpacing = false -- << toggle spacing between every 2 characters

local characters = 'abcdef1234567890'

local function gen(e)
    local randomized = ""
    for i = 1, e do
        local idx = math.random(#characters)
        randomized = randomized .. characters:sub(idx, idx)
    end

    if uppercase then
        randomized = string.upper(randomized)
    end

    if useSpacing then
        local spaced = {}
        for i = 1, #randomized, 2 do
            table.insert(spaced, randomized:sub(i, i+1))
        end
        randomized = table.concat(spaced, " ")
    end

    return randomized
end

math.randomseed(os.time())

for i = 1, how_many do
    print(i .. ". " .. gen(length))
end
INFO