1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Key Generator

Discussion in 'Snippets' started by PatoFrango, Jul 5, 2018.

  1. PatoFrango

    PatoFrango Active Member

    Jul 12, 2017
    Likes Received:
    This function generates a random key (using numbers and lower, upper case letters) with a given amount of characters.

    Code (Skript):
    1. function genKey(l: number) :: text:
    2.     set {_abc} to "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuYvVwWxXyYzZ"
    3.     loop {_l} times:
    4.         set {_t} to random integer between 1 and 52
    5.         set {_n} to random integer between 0 and 9
    6.         if {_r} is set:
    7.             chance of 50%:
    8.                 set {_r} to "%{_r}%%subtext of {_abc} from characters {_t} to {_t}%"
    9.             else:
    10.                 set {_r} to "%{_r}%%{_n}%"
    11.         else:
    12.             chance of 50%:
    13.                 set {_r} to subtext of {_abc} from characters {_t} to {_t}
    14.             else:
    15.                 set {_r} to {_n}
    16.     return {_r}
    Code (Skript):
    1. # e.g.
    2. genKey(20)
    3. # generates a random key with 20 characters
    Code (Skript):
    1. # e.g.
    2. 5dA3bE9PH636PGc9J55d

Share This Page