Login Register






[Ruby] Passgen [Updated] filter_list
Author
Message
[Ruby] Passgen [Updated] #1
I decided to make a random password generator because narwhals and the unicorn on Canadian parliament (I shit you not, it exists (Pic)).

It outputs itself to password list.txt in an array format, mainly because I don't know how to get it to do anything else but it could be useful for use in another program on import.

Anyway, enjoy!

Code:
#Passgen by Nightc||ed, ©2015 norm = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] caps = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] puts "How many passwords would you like to generate?" num = gets.to_i system "cls" puts "Password length:" len = gets.to_i system "cls" puts """ Which characters would you like to use? [1] a-z, 0-9 [2] A-Z, 0-9 [3] a-z, A-Z, 0-9 """ type = gets.chomp system "cls" case type when "1" arr = [norm,nums].flatten when "2" arr = [caps,nums].flatten when "3" arr = [norm,caps,nums].flatten else exit end passwd_set = [] output = File.open("password list.txt", "w") passwd_set << arr.sample(len).join output << passwd_set



Update:
More efficient

Code:
#Password list generator by Nightc||ed, ©2015 norm = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"] caps = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] puts "How many passwords would you like to generate?" num = gets.to_i system "cls" puts "Password length:" len = gets.to_i system "cls" puts """ Which characters would you like to use? [1] a-z, 0-9 [2] A-Z, 0-9 [3] a-z, A-Z, 0-9 """ type = gets.chomp system "cls" case type when "1" arr = [norm,nums].flatten when "2" arr = [caps,nums].flatten when "3" arr = [norm,caps,nums].flatten else exit end passwd_set = [] output = File.open("password list.txt", "w") num.times do passwd_set << arr.sample(len).join end output << passwd_set
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.

Reply