Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- PASSWORD GENERATOR (thing):
- Time Taken: 4 hours
- Amount of lines: 169
- Language: Lua
- Description: Yeah, scratch is gross
- HOW TO USE:
- 1) Head to this link: https://rextester.com/l/lua_online_compiler
- 2) Copy and paste this script into the box
- 3) Enter in text of any kind into the variable "INPUT" located at line 18
- 4) To acknowledge seperate words, use one captial letter or an underscore.
- 5) Press "Run it (F8)" located towards the bottom of the page to execute the script.
- EXAMPLE INPUT:
- local INPUT = "FacebookIsGross"
- local INPUT = "Facebook_is_gross"
- ]]
- local INPUT = "FacebookIsGross"
- seed = 1 -- debug number, change to re-randomize
- alphabet = {} -- optimized use of an alphabet
- alphabet["a"] = "a";alphabet["b"] = "b";alphabet["c"] = "c";alphabet["d"] = "d";alphabet["e"] = "e";alphabet["f"] = "f";alphabet["g"] = "g";alphabet["h"] = "h";alphabet["i"] = "i";alphabet["j"] = "j";alphabet["k"] = "k";alphabet["l"] = "l";alphabet["m"] = "m";alphabet["n"] = "n";alphabet["o"] = "o";alphabet["p"] = "p";alphabet["q"] = "q";alphabet["r"] = "r";alphabet["s"] = "s";alphabet["t"] = "t";alphabet["u"] = "u";alphabet["v"] = "v";alphabet["w"] = "w";alphabet["x"] = "x";alphabet["y"] = "y";alphabet["z"] = "z"
- function isVowel(letter) -- This will determine whether a letter is a vowel or not.
- if letter:lower() == "a" or letter:lower() == "e" or letter:lower() == "i" or letter:lower() == "o" or letter:lower() == "u" then
- return true
- else
- return false
- end
- end
- function getKeyCharacters(word)
- for i=1,#word do
- -- put seed here
- local math = math.random(1,6)
- if isVowel(string.sub(word,i,i)) == true then -- if the current letter is a vowel or not
- if math ~= 6 then -- if math does not equal 6
- word = string.sub(word,1,i-1)..string.sub(word,i+1) -- remove the vowel
- if #word == i then -- if the length of the word had reached the amount of i, break the loop to avoid warping the word
- break
- end
- end
- end
- end
- for k=1,#word do -- domain loop
- for i=1,#word do -- range loop
- -- this condition was required in order to skip very strange issues
- if string.sub(word,i,i):lower() ~= "a" and string.sub(word,i,i):lower() ~= "b" and string.sub(word,i,i):lower() ~= "c" and string.sub(word,i,i):lower() ~= "d" and string.sub(word,i,i):lower() ~= "e" and string.sub(word,i,i):lower() ~= "f" and string.sub(word,i,i):lower() ~= "g" and string.sub(word,i,i):lower() ~= "h" and string.sub(word,i,i):lower() ~= "i" and string.sub(word,i,i):lower() ~= "j" and string.sub(word,i,i):lower() ~= "k" and string.sub(word,i,i):lower() ~= "l" and string.sub(word,i,i):lower() ~= "m" and string.sub(word,i,i):lower() ~= "n" and string.sub(word,i,i):lower() ~= "o" and string.sub(word,i,i):lower() ~= "p" and string.sub(word,i,i):lower() ~= "q" and string.sub(word,i,i):lower() ~= "r" and string.sub(word,i,i):lower() ~= "s" and string.sub(word,i,i):lower() ~= "t" and string.sub(word,i,i):lower() ~= "u" and string.sub(word,i,i):lower() ~= "v" and string.sub(word,i,i):lower() ~= "w" and string.sub(word,i,i):lower() ~= "x" and string.sub(word,i,i):lower() ~= "y" and string.sub(word,i,i):lower() ~= "z" and string.sub(word,i,i):lower() ~= "_" and string.sub(word,i,i):lower() ~= "-" then
- word = string.sub(word,1,i-1)..string.sub(word,i+1,#word) -- remove the special character
- break -- stop the current loop from running
- end
- end
- end
- return word
- end
- function cleanArray(array) -- I didn't want to take the time to polish the seperateWords function, so I just added this.
- local elim = 0
- for i=1,#array do
- if array[i] == "" or array[i] == " " or array[i] == "-" or array[i] == "_" then -- of the component of array is empty, remove it
- table.remove(array,i)
- elim = elim + 1 -- just incase we need to print anything
- end
- end
- return array
- end
- function seperateWords(word)
- local arr = {} -- cache the array for later use
- local last = 1 -- where the last change occured
- local lastlet = true -- a variable to tell if the last change was a letter or not to avoid mixed characters
- for i=1,#word do
- if alphabet[string.sub(word,i,i):lower()] ~= nil and string.sub(word,i,i) == string.sub(word,i,i):upper() and last == 1 then -- if the character is a captial letter, and no previous changes have occured, then seperate it into an array
- if lastlet == true and i ~= 1 then
- table.insert(arr,string.sub(word,last,i-1))
- elseif lastlet == false and i ~= 1 then
- table.insert(arr,string.sub(word,last+1,i-1))
- end
- last = i
- lastlet = true
- elseif alphabet[string.sub(word,i,i):lower()] ~= nil and string.sub(word,i,i) == string.sub(word,i,i):upper() and last ~= 1 then -- if the character is a captial letter, and there has been previous changes, then seperate it into an array accordingly.
- if lastlet == true then
- table.insert(arr,string.sub(word,last,i-1))
- else
- table.insert(arr,string.sub(word,last+1,i-1))
- end
- last = i
- lastlet = true
- elseif (string.sub(word,i,i) == "-" or string.sub(word,i,i) == "_") and last == 1 then -- if the character is a dash or an underscore, and no previous changes have occured, then seperate it into an array.
- if lastlet == true and i ~= 1 then
- table.insert(arr,string.sub(word,last,i-1))
- elseif lastlet == false and i ~= 1 then
- table.insert(arr,string.sub(word,last+1,i-1))
- end
- last = i
- lastlet = false
- elseif (string.sub(word,i,i) == "-" or string.sub(word,i,i) == "_") and last ~= 1 then -- if the character is a dash or an underscore, and there has been previous changes, then seperate it into an array accordingly.
- if lastlet == true then
- table.insert(arr,string.sub(word,last,i-1))
- else
- table.insert(arr,string.sub(word,last+1,i-1))
- end
- last = i
- lastlet = false
- elseif i == #word then -- if the loop is ending and no other conditions were true, add the last word.
- if lastlet == true then
- table.insert(arr,string.sub(word,last,i))
- else
- table.insert(arr,string.sub(word,last+1,i))
- end
- end
- end
- return arr
- end
- function insertSpecial(x)
- local place;
- for i=1,seed do
- place = math.random(1,#x) -- the place to insert the special
- end
- local specials = {"!","@","#","$","%","&","*","<",">","?","/"}
- x = string.sub(x,1,place)..specials[math.random(1,#specials)]..string.sub(x,place+1)
- return x
- end
- function insertNumber(x)
- local place;
- for i=1,seed do
- place = math.random(1,#x) -- the place to insert the number
- end
- x = string.sub(x,1,place)..math.random(0,9)..string.sub(x,place+1)
- return x
- end
- -- This is where the actual script starts
- function inputP(input)
- local Password = getKeyCharacters(input)
- local passwrd = "" -- chached variable for later
- local arrayWords = cleanArray(seperateWords(Password))
- local random1;
- local random2;
- local random3;
- local random4;
- local random5;
- local random6;
- local random7;
- local random8;
- for i=1,#arrayWords do
- local word = arrayWords[i] -- current word
- --[[ Cached variables ]]
- for i=1,seed do
- random1 = math.random(1,4) -- random special character
- random2 = math.random(1,2) -- captilization
- random3 = math.random(1,#arrayWords) -- get a random number from 1 to the length of the current word
- random4 = math.random(1,#arrayWords)
- random5 = math.random(1,4) -- random special number
- random6 = math.random(1,2) -- numbers at ending?
- random7 = math.random(1,3) -- how many numbers at ending
- random8 = math.random(0,99) -- what number
- end
- if random2 == 1 then
- word = word:upper()
- else
- word = word:lower()
- end
- if random1 == 4 then
- word = insertSpecial(word)
- end
- if random5 == 4 then
- word = insertNumber(word)
- end
- passwrd = passwrd..word
- end
- if random6 == 1 then
- for i=1,random7 do
- passwrd = passwrd..random8
- end
- end
- return passwrd
- end
- for i=1,100 do
- local pass = inputP(INPUT) -- all characters that aren't seperate words should not be captilized.
- print(i.." | "..pass)
- seed = seed + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement