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
···
--
Posted via http://www.ruby-forum.com/.
http://highline.rubyforge.org/
-greg
···
On Wed, Jan 21, 2009 at 1:39 PM, John Chant <john.chant@gmail.com> 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.
--
Technical Blaag at: http://blog.majesticseacreature.com
Non-tech stuff at: http://metametta.blogspot.com
"Ruby Best Practices" Book now in O'Reilly Roughcuts:
http://rubybestpractices.com
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 10:39 AM, John Chant <john.chant@gmail.com> 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).
Thanks, that is simple, but where do I find Password?, what requires do I
need?
···
2009/1/21 Ben Bleything <ben@bleything.net>
On Wed, Jan 21, 2009 at 10:39 AM, John Chant <john.chant@gmail.com> 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:
Ruby/Password
It's pretty simple:
Password.get( "Your prompt: " )
Ben
* Bertram Scharpf <lists@bertram-scharpf.de> [2009-01-22 20:20:27 +0900]:
Hi,
> 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
···
Am Donnerstag, 22. Jan 2009, 03:39:57 +0900 schrieb John Chant:
--
Saji N. Hameed
APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 saji@apcc21.net
KOREA
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
···
On Wed, Jan 21, 2009 at 11:08 AM, John Chant <john.chant@gmail.com> wrote:
Thanks, that is simple, but where do I find Password?, what requires do I
need?
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 }
···
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