On Thu, Jan 22, 2009 at 6:33 AM, Saji N. Hameed <saji / apcc21.net> wrote:
> * Bertram Scharpf <lists / bertram-scharpf.de> [2009-01-22 20:20:27 +0900]:
>
>> Hi,
>>
>> Am Donnerstag, 22. Jan 2009, 03:39:57 +0900 schrieb John Chant:
>> > I would like to be able to read a password without echoing the
>> > characters typed. I've looked at getc but this echos the character (as a
>> > number).
>>
>> http://bertram-scharpf.homelinux.com/src/password.rb
>>
>> Needs the termios gem and UN*X.
>
> an alternative suggestion is ...
>
>  def get_password
>      print "Password: "
>      `stty -echo`
>      @pass=STDIN.gets.chomp ensure `stty echo`
>  end

It's worth mentioning that of all the solutions recommended, Highline
is the only one that works cross-platform comfortably.

require "highline/import"

pass = ask("Enter your password:  ") { |q| q.echo = false }