[Nh-pm] encryption recommendation

Ben Boulanger ben at blackavar.com
Mon Aug 4 09:15:59 CDT 2003


On Mon, 2003-08-04 at 09:25, Andrew Brosnan wrote:
> Can someone recommend a method or module for encrypting and decrypting strings(passwords)? I'm a little overwhelmed by the choices on the CPAN, some of which have quite a long list of dependencies.

If you're looking for simple, I just use the crypt routine.  Here's
sample code:

my $salt = &generate_random_salt;
my $password = crypt($password, $salt);

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;
        my $return_salt = $range[$random_number1] .
$range[$random_number2];
        return $return_salt;
}





More information about the Nh-pm mailing list