Passwords


#1

Hi,

I’m new to Ruby ( one day), but not to programming (over 30 years) and I
would like some help.

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).

Something like the python getpass would be good.

John C.


#2

On Wed, Jan 21, 2009 at 1:39 PM, John C. removed_email_address@domain.invalid
wrote:

Hi,

I’m new to Ruby ( one day), but not to programming (over 30 years) and I
would like some help.

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).

Something like the python getpass would be good.

http://highline.rubyforge.org/

-greg


#3

On Wed, Jan 21, 2009 at 10:39 AM, John C. removed_email_address@domain.invalid
wrote:

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).

The Ruby-Password library supports this. Check it out:
http://www.caliban.org/ruby/ruby-password.shtml

It’s pretty simple:

Password.get( "Your prompt: " )

Ben


#4

On Wed, Jan 21, 2009 at 11:08 AM, John C. removed_email_address@domain.invalid
wrote:

Thanks, that is simple, but where do I find Password?, what requires do I
need?

All of that information and more is available at the link I gave you.
It requires ruby-termios (which is available as a gem) and cracklib,
which should be available from your operating system’s package
manager.

Ben


#5

Thanks, that is simple, but where do I find Password?, what requires do
I
need?

2009/1/21 Ben B. removed_email_address@domain.invalid


#6

Hi,

Am Donnerstag, 22. Jan 2009, 03:39:57 +0900 schrieb John C.:

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.

Bertram


#7

Hi,

Am Donnerstag, 22. Jan 2009, 03:39:57 +0900 schrieb John C.:

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


Saji N. Hameed

APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 removed_email_address@domain.invalid
KOREA


#8

On Thu, Jan 22, 2009 at 6:33 AM, Saji N. Hameed removed_email_address@domain.invalid wrote:

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 }