How to Hide Password Characters in STDIN Perl Windows

Perl is a popular scripting language used by system administrators to automate processes on their computers. It's a powerful interface designed to be used from the command prompt, but many developers are concerned about the way Perl's standard input shows all characters typed (or echos), since this poses a security risk when entering passwords. To hide password characters, you must install the Term::ReadKey library from the Perl CPAN. Though some features from the Term::ReadKey library do not work with Windows, the "noecho" mode works properly.

Things You'll Need

  • Term::ReadKey
Show More

Instructions

    • 1

      Open a text editor, create and save a file with the name "passwordtest.pl."

    • 2

      Paste the following into the file to load the "Term::ReadKey" library:

      use Term::ReadKey;

    • 3

      Paste the following code to prompt the user for a password:

      print 'Please enter your password: ';

    • 4

      Paste the following to turn off the keyboard echos:

      ReadMode 'noecho';

    • 5

      Paste the following to read the password:

      my $password = ReadLine;

    • 6

      Paste the following to turn keyboard echos back off:

      ReadMode 'normal';

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured