Created
May 7, 2013 17:25
-
-
Save apeiros/5534417 to your computer and use it in GitHub Desktop.
Enter passwords in pry/irb without echo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'io/console' # requires ruby 1.9.3 | |
module PasswordString | |
def inspect; "[PASSWORD]"; end | |
def to_s; "[PASSWORD]"; end | |
def dup; obj=super;obj.extend PasswordString; obj; end | |
def clone; obj=super;obj.extend PasswordString; obj; end | |
end | |
def password | |
r = $stdin.noecho { gets.chomp } | |
r.extend PasswordString | |
r | |
end | |
alias secret password |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment