Advertisement
BobMe

PASS GEN

Nov 7th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.99 KB | None | 0 0
  1. --[[
  2. PASSWORD GENERATOR (thing):
  3. Time Taken: 4 hours
  4. Amount of lines: 169
  5. Language: Lua
  6. Description: Yeah, scratch is gross
  7.  
  8. HOW TO USE:
  9. 1) Head to this link: https://rextester.com/l/lua_online_compiler
  10. 2) Copy and paste this script into the box
  11. 3) Enter in text of any kind into the variable "INPUT" located at line 18
  12. 4) To acknowledge seperate words, use one captial letter or an underscore.
  13. 5) Press "Run it (F8)" located towards the bottom of the page to execute the script.
  14.  
  15. EXAMPLE INPUT:
  16. local INPUT = "FacebookIsGross"
  17. local INPUT = "Facebook_is_gross"
  18. ]]
  19. local INPUT = "FacebookIsGross"
  20.  
  21.  
  22.  
  23. seed = 1 -- debug number, change to re-randomize
  24. alphabet = {} -- optimized use of an alphabet
  25. 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"
  26.  
  27.  
  28. function isVowel(letter) -- This will determine whether a letter is a vowel or not.
  29. if letter:lower() == "a" or letter:lower() == "e" or letter:lower() == "i" or letter:lower() == "o" or letter:lower() == "u" then
  30. return true
  31. else
  32. return false
  33. end
  34. end
  35.  
  36.  
  37. function getKeyCharacters(word)
  38. for i=1,#word do
  39. -- put seed here
  40. local math = math.random(1,6)
  41. if isVowel(string.sub(word,i,i)) == true then -- if the current letter is a vowel or not
  42. if math ~= 6 then -- if math does not equal 6
  43. word = string.sub(word,1,i-1)..string.sub(word,i+1) -- remove the vowel
  44. if #word == i then -- if the length of the word had reached the amount of i, break the loop to avoid warping the word
  45. break
  46. end
  47. end
  48. end
  49. end
  50. for k=1,#word do -- domain loop
  51. for i=1,#word do -- range loop
  52. -- this condition was required in order to skip very strange issues
  53. 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
  54. word = string.sub(word,1,i-1)..string.sub(word,i+1,#word) -- remove the special character
  55. break -- stop the current loop from running
  56. end
  57. end
  58. end
  59. return word
  60. end
  61.  
  62. function cleanArray(array) -- I didn't want to take the time to polish the seperateWords function, so I just added this.
  63. local elim = 0
  64. for i=1,#array do
  65. if array[i] == "" or array[i] == " " or array[i] == "-" or array[i] == "_" then -- of the component of array is empty, remove it
  66. table.remove(array,i)
  67. elim = elim + 1 -- just incase we need to print anything
  68. end
  69. end
  70. return array
  71. end
  72.  
  73. function seperateWords(word)
  74. local arr = {} -- cache the array for later use
  75. local last = 1 -- where the last change occured
  76. local lastlet = true -- a variable to tell if the last change was a letter or not to avoid mixed characters
  77. for i=1,#word do
  78. 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
  79. if lastlet == true and i ~= 1 then
  80. table.insert(arr,string.sub(word,last,i-1))
  81. elseif lastlet == false and i ~= 1 then
  82. table.insert(arr,string.sub(word,last+1,i-1))
  83. end
  84. last = i
  85. lastlet = true
  86. 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.
  87. if lastlet == true then
  88. table.insert(arr,string.sub(word,last,i-1))
  89. else
  90. table.insert(arr,string.sub(word,last+1,i-1))
  91. end
  92. last = i
  93. lastlet = true
  94. 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.
  95. if lastlet == true and i ~= 1 then
  96. table.insert(arr,string.sub(word,last,i-1))
  97. elseif lastlet == false and i ~= 1 then
  98. table.insert(arr,string.sub(word,last+1,i-1))
  99. end
  100. last = i
  101. lastlet = false
  102. 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.
  103. if lastlet == true then
  104. table.insert(arr,string.sub(word,last,i-1))
  105. else
  106. table.insert(arr,string.sub(word,last+1,i-1))
  107. end
  108. last = i
  109. lastlet = false
  110. elseif i == #word then -- if the loop is ending and no other conditions were true, add the last word.
  111. if lastlet == true then
  112. table.insert(arr,string.sub(word,last,i))
  113. else
  114. table.insert(arr,string.sub(word,last+1,i))
  115. end
  116. end
  117. end
  118. return arr
  119. end
  120.  
  121. function insertSpecial(x)
  122. local place;
  123. for i=1,seed do
  124. place = math.random(1,#x) -- the place to insert the special
  125. end
  126. local specials = {"!","@","#","$","%","&","*","<",">","?","/"}
  127. x = string.sub(x,1,place)..specials[math.random(1,#specials)]..string.sub(x,place+1)
  128. return x
  129. end
  130.  
  131. function insertNumber(x)
  132. local place;
  133. for i=1,seed do
  134. place = math.random(1,#x) -- the place to insert the number
  135. end
  136. x = string.sub(x,1,place)..math.random(0,9)..string.sub(x,place+1)
  137. return x
  138. end
  139.  
  140. -- This is where the actual script starts
  141. function inputP(input)
  142. local Password = getKeyCharacters(input)
  143. local passwrd = "" -- chached variable for later
  144. local arrayWords = cleanArray(seperateWords(Password))
  145. local random1;
  146. local random2;
  147. local random3;
  148. local random4;
  149. local random5;
  150. local random6;
  151. local random7;
  152. local random8;
  153. for i=1,#arrayWords do
  154. local word = arrayWords[i] -- current word
  155. --[[ Cached variables ]]
  156. for i=1,seed do
  157. random1 = math.random(1,4) -- random special character
  158. random2 = math.random(1,2) -- captilization
  159. random3 = math.random(1,#arrayWords) -- get a random number from 1 to the length of the current word
  160. random4 = math.random(1,#arrayWords)
  161. random5 = math.random(1,4) -- random special number
  162. random6 = math.random(1,2) -- numbers at ending?
  163. random7 = math.random(1,3) -- how many numbers at ending
  164. random8 = math.random(0,99) -- what number
  165. end
  166. if random2 == 1 then
  167. word = word:upper()
  168. else
  169. word = word:lower()
  170. end
  171. if random1 == 4 then
  172. word = insertSpecial(word)
  173. end
  174. if random5 == 4 then
  175. word = insertNumber(word)
  176. end
  177. passwrd = passwrd..word
  178. end
  179. if random6 == 1 then
  180. for i=1,random7 do
  181. passwrd = passwrd..random8
  182. end
  183. end
  184. return passwrd
  185. end
  186.  
  187. for i=1,100 do
  188. local pass = inputP(INPUT) -- all characters that aren't seperate words should not be captilized.
  189. print(i.." | "..pass)
  190. seed = seed + 1
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement