#!/perl/bin/perl

# encrypt.pl
# Second version. Takes a password from the command
# line, encrypts it, and writes it to a file.

    $PwdFileName = "password";        # A name for password file.
    $PassWordString = $ARGV[0];       # Get command line argument.

# Use crypt() with a "salt" of "" to encrypt the string
# that was entered.

    $EncryptedPassword = crypt ($PassWordString, "");

# Now create the password file and write the encrypted string.

    open (PWD, ">$PwdFileName") ||
        die "Can't open $PwdFileName for writing: $!\n";

    print PWD $EncryptedPassword;
    close (PWD);

#                    End encrypt.pl
