repl.it
@anonymous/

DisguisedLoathsomeXuanhuasaurus

Ruby

No description

fork
loading
Files
  • main.rb
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
letters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"
numbers = "1234567890"
symbols = "~`[email protected]#$%^&*()-_+=;:/?.,><"

use_letters = FALSE
use_numbers = FALSE
use_symbols = FALSE

print "What length would you like the password to be?\n"
pass_length = gets.chomp.to_i

print "Use Letters? (Y/N)\n"
lResponse = gets.chomp.upcase
if lResponse == "Y"
  use_letters = TRUE
end

print "Use Numbers? (Y/N) \n"
nResponse = gets.chomp.upcase
if nResponse == "Y"
  use_numbers = TRUE
end

print "Use Symbols? (Y/N)\n"
sResponse = gets.chomp.upcase
if sResponse == "Y"
  use_symbols = TRUE
end

pass_string = (use_letters ? letters : "") + (use_numbers ? numbers : "") + (use_symbols ? symbols : "")
pass_string = pass_string.split("")
pass_string = pass_string.shuffle.shuffle.join
print ((pass_string.length > pass_length) ? pass_string[0...pass_length] : pass_string)
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux]
?