#! /usr/bin/perl # PERL script to quickly generate a password (one could use # mkpasswd as well). The password generated with this script # has its first two characters as the 'salt' defined below, # easily indicating whether the user has changed the temporary # password or not. # Patrick Krogel, Michigan Technological University # Salt - common practice is to choose SI's initials $salt = "sg"; sub encrypt($) { my $pass = shift; my $epass = crypt($pass,$salt); return $epass; } # Step 1: Get Password (twice) system("stty -echo"); print "Enter password: "; $pass1 = ; chomp ($pass1); print "\nConfirm password: "; $pass2 = ; chomp ($pass2); system("stty echo"); # Compare the user entry and process it if (! -z $pass1 && $pass1 eq $pass2) { $epass = encrypt($pass1); print "\nPassword: $epass\n"; } elsif ($pass1 ne $pass2) { print "\nPasswords don't match.\n"; } else { print "\nPassword is blank.\n"; }