#!/usr/bin/perl #-------------------------------------------------------------------- # This script has been heavlily hacked from Suso Banderas' version. #-------------------------------------------------------------------- # # encrypt Encrypt a word in many ways # Copyright (C) 1999 Suso Banderas # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # You may contact the author at . use Getopt::Std; getopts('hvs:'); $commandline_password_input = $ARGV[0]; $password_salt = $opt_s || &generate_random_salt; ################## ## MAIN PROGRAM ## ################## if ($opt_h || $opt_v) { &usage; exit(0); } if (defined $commandline_password_input) { $password = $commandline_password_input; } $encrypted_password = &encrypt_word($password, $password_salt); print "$encrypted_password\n"; exit(0); ################# ## SUBROUTINES ## ################# sub usage { print < -- Specify the salt to use for encryption. END } sub encrypt_word { my $password = shift; my $salt = shift; $return_encrypted_password = crypt($password, $salt); return $return_encrypted_password; } sub generate_random_salt { my @range = ('A'..'Z','a'..'z','0'..'9','.','/'); my $highest_array_value = $#range; my $random_number1 = rand $highest_array_value; my $random_number2 = rand $highest_array_value; $return_salt = $range[$random_number1] . $range[$random_number2]; return $return_salt; }