I am new to ruby. I need to receive password as an input through gets
command.
How do I hide the password input typed in the terminal, during gets
One can also use core ruby.
$ ri IO.noecho
(from ruby core)
------------------------------------------------------------------------------
io.noecho {|io| }
------------------------------------------------------------------------------
Yields self with disabling echo back.
STDIN.noecho(&:gets)
will read and return a line without echo back.
For 1.9.3 (and above), this requires you adding require 'io/console'
to your code.
require 'io/console'
text = STDIN.noecho(&:gets)