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.
On Wed, Jan 21, 2009 at 1:39 PM, John C. [email protected]
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
On Wed, Jan 21, 2009 at 10:39 AM, John C. [email protected]
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
On Wed, Jan 21, 2009 at 11:08 AM, John C. [email protected]
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
Thanks, that is simple, but where do I find Password?, what requires do
I
need?
2009/1/21 Ben B. [email protected]
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
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 [email protected]
KOREA
On Thu, Jan 22, 2009 at 6:33 AM, Saji N. Hameed [email protected] 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 }