Key Generator

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

PatoFrango

Active Member
Jul 12, 2017
240
14
18
This function generates a random key (using numbers and lower, upper case letters) with a given amount of characters.

Code:
code_language.skript:
function genKey(l: number) :: text:
    set {_abc} to "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuYvVwWxXyYzZ"
    loop {_l} times:
        set {_t} to random integer between 1 and 52
        set {_n} to random integer between 0 and 9
        if {_r} is set:
            chance of 50%:
                set {_r} to "%{_r}%%subtext of {_abc} from characters {_t} to {_t}%"
            else:
                set {_r} to "%{_r}%%{_n}%"
        else:
            chance of 50%:
                set {_r} to subtext of {_abc} from characters {_t} to {_t}
            else:
                set {_r} to {_n}
    return {_r}

Usage:
code_language.skript:
# e.g.
genKey(20)
# generates a random key with 20 characters

Output:
code_language.skript:
# e.g.
5dA3bE9PH636PGc9J55d