obfuscation - Hide user input in Ruby -


i'm looking read in data user, however, not want input show directly on screen. rather, i'd leave blank or better yet, obfuscate characters input astericks.

for example:

print "password: " pass = stdin.gets.chomp 

assuming using @ least ruby 1.9, can use noecho method on io: http://www.ruby-doc.org/stdlib-2.0/libdoc/io/console/rdoc/io.html#method-i-noecho

so:

require 'io/console' print "password: " stdin.noecho(&:gets).chomp 

this not obfuscate characters, leave input terminal blank.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -