Capitalization In Tables?

Hey everyone. Let’s say I wanted to make a random password generator using Lua.

If I had a set of characters I wanted to use in the passwords,

local char = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "<", ">", "?",}

But I wanted to have both lower case characters and upper case characters, would I have to have the same character twice but for both lower and upper case?

local char = {"a", "A"}

you can just do a math.random check, if 0 use string.lower, if 1 use string.upper on the character

I’d also recommend just using math.random for this entire thing and converting it from byte code to a string instead of having a table full of letters.

I wouldn’t do this if you want a random password,
Use GenerateGUID

1 Like

33 - 126

local function CreateCharacters()
    local characters = {}
    for i = 33, 126 do
        table.insert(characters, string.char(i))
    end
    return characters
end

local Characters = CreateCharacters()

perhaps he wants customizable lengths and he doesn’t want hyphens in his password? he also said that he wanted uppercase letters which UUIDs dont use.

that’s editable bro…
GenerateGUID can work

Anyways, why do you want that?
I don’t get it.

No it’s not. GenerateGUID can only provide a UUID. The parameter allows it to be wrapped in brackets automatically or not. GenerateGUID will not work for his intended use, which is to have a generated password that also has upper and lowercase characters

That’s right, customizable lengths would preferable.

Does ‘GenerateGUID’ only have an output something like this?
{04AEBFEA-87FC-480F-A98B-E5E221007A90}

I’m assuming it does.

yeah, there’s no customizability