概要
標準入力からパスワードをechoせずに入力する
詳細
標準入力からパスワードをechoせずに入力します。
サンプル
# encoding: utf-8 require 'io/console' require 'tbpgr_utils' print "Enter password: " password = STDIN.noecho(&:gets).chop puts puts_eval "password", binding __END__ 下記はTbpgrUtils gemの機能 puts_eval 詳しくは下記参照 https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
※「Enter password: 」の部分は実際にはpasswordと入力しているが表示されていない
$ ruby password_stdin.rb
Enter password:
password # => "password"