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
Post a Comment