Skip to content

Instantly share code, notes, and snippets.

@dothenotive
Created January 24, 2022 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dothenotive/c0344c723331f169d26560a3050cae50 to your computer and use it in GitHub Desktop.
Save dothenotive/c0344c723331f169d26560a3050cae50 to your computer and use it in GitHub Desktop.
math.randomseed(os.clock()^math.random(1, 5))
local character_set = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890аәӕбвгґғҕдԁђԃҙеєжҗзԅѕӡԇиҋіјкқӄҡҟҝлӆљԉмӎнӊңӈҥњԋоөпҧҁрҏсԍҫтԏҭћуүұѹфхҳһѡѿѽѻцҵчҷӌҹҽҿџшщъыьҍѣэюяѥѧѫѩѭѯѱѳѵҩӀӀ۱۲۳۴۵۶۷۸۹ءٴٲٱٳاٮبٻپڀةتثٹٺټٽٿجڃڄچڿڇحخځڂڅدذڈډڊڋڌڍڎڏڐرزڑڒړڔڕږڗژڙسشښڛڜۺصضڝڞۻطظڟعغڠۼفڡڢڣڤڥڦٯقڧڨكکڪګڬڭڮگڰڱڲڳڴلڵڶڷڸمنںڻڼڽڹهھہۃەوۥۄۅۆۇۈۉۊۋۏىيۦیۍێېۑے"
local character_set_amount = #character_set
local number_one = 1
local default_length = 10
local function generate_key(length)
local random_string = {}
for int = number_one, length or default_length do
local random_number = math.random(number_one, character_set_amount)
local character = string.sub(character_set, random_number, random_number)
random_string[#random_string + number_one] = character
end
return table.concat(random_string)
end
generate_key()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment