#!/usr/bin/perl # FILE: encrypt_it_2 # Demonstrates how to make sure person running this program knows their # own password. Assumes unix system. # When verifying an existing encrypted string, you should use the # encrypted text as the SALT: crypt($plain,$crypted) eq $cypted use warnings; use strict; my $pwd = (getpwuid ($<)) [1]; #sets pwd to user's own password `stty -echo`; print ("what is your password?\n"); chomp(my $answer = ); `stty echo`; if (crypt($answer,$pwd) eq $pwd) { print "success" } else { print "failure" } print "\n";