Skip to content

Instantly share code, notes, and snippets.

@bitaxis
Created August 16, 2020 20:10
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 bitaxis/8521baea1805cfc23d658f594da37ca7 to your computer and use it in GitHub Desktop.
Save bitaxis/8521baea1805cfc23d658f594da37ca7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
password_length = (ARGV[0] || 16).to_i
symbol_count = (ARGV[1] || 2).to_i
alphanumerics = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
symbols = "~`!@##$%^&-=_+()[]{};:,.".chars
50.times do
password = password_length.times.collect { alphanumerics[Random.rand(0...alphanumerics.length)] }.join
symbol_count.times { password[Random.rand(0...password.length)] = symbols[Random.rand(0...symbols.length)] }
puts password
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment