The crypt function encrypts a string using the NBS Data Encryption Standard (DES) algorithm.
#!/usr/local/bin/perl
open (PASSWD, "/u/jqpublic/passwd") || die ("Can't open password file");
$passwd = <PASSWD>;
chop ($passwd);
close (PASSWD);
$mypasswd = "asdf";
if (crypt ($mypasswd, substr($passwd, 0, 2)) eq $passwd) {
print ("Correct! Carry on!\n");
} else {
die ("Incorrect password: goodbye!\n");
}
Related examples in the same category