Passwords

J

John Chant

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 Chant
 
G

Gregory Brown

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
 
J

John Chant

[Note: parts of this message were removed to make it a legal post.]

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

Ben Bleything

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
 
S

Saji N. Hameed

* Bertram Scharpf said:
Hi,

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

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 (e-mail address removed)
KOREA
 
G

Gregory Brown

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 }
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,968
Members
47,524
Latest member
ecomwebdesign

Latest Threads

Top