LoginSignup
0
0

More than 3 years have passed since last update.

Rubyでもいい感じにパスワードを出して欲しい

Last updated at Posted at 2020-02-28

イメージ

確かにLinuxだったらさ、コマンドでランダムなパスワードとか出せると思うけどRubyでもやりたいじゃんと思って考え中

やり方

securerandomというライブラリを使えばランダムな値を簡単に生成できるので便利かも

実行方法

ruby randompw.rb [パスワードの桁数]

randompw.rb
require 'securerandom'

i = ARGV[0]
#puts i
puts SecureRandom.alphanumeric(i.to_i)

感想

こんな感じにSecurerandomのライブラリを使って何桁のパスワードを出力して欲しいかを入れるだけ

こうすると、とりあえずランダムなパスワードがいい感じができるのでちょっと満足した。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0