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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -