Thanks John and Chas!

> [EMAIL PROTECTED] wrote:
>> Hey folks,
>
> Hello,
>
>> I have been using crypt for a while. No problems until recently.
>>
>> Problem crypt does not return a hash that matches getpwnam(). I have
>> been
>> using crypt for a long time without any problems.
>>
>> Bellow is test script I have using for testing hashs. The output of the
>> script bellow is as follows(Note passwd  for user "test" is "hello"):
>>
>> linux:/tmp# ./perltest.pl
>> Enter a string to encrypt with DES: hello
>> Enter two random alphanumerics to be used as a salt:n$!
>>
>> "hello" encrypted using the perl crypt() function and salt "$!" returns:
>> $!8VHq6xLWgQc  $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
>>
>> crypt returns= $!8VHq6xLWgQc
>> hash value returned by getpwnam= $1$70w840Bc$Hkmqjlz8N7abM2SGlLm0T1
>>
>> I have tested crypt() on debian, and redhat. Same problems. The has
>> values
>> do not match each other.
>>
>> Please help, any suggestions.
>>
>> thanks
>>
>> jerry
>>
>> #########################################################################
>> Perl script bellow
>> #########################################################################
>> #!/usr/bin/perl
>>
>> print "Enter a string to encrypt with DES:n";
>> chomp(my $string = <STDIN>); #Take the input from the user and remove
>> the n
>>
>> print "Enter two random alphanumerics to be used as a salt:n";
>> chomp(my $salt = <STDIN>);
>>
>> my $encrypted_string = crypt($string,$salt); #take the string and the
>> salt
>> and put through crypt()
>>
>> $pass = (getpwnam(test))[1];
>
> You need to use the old password as the salt, so change that to:
>
> my $pass = ( getpwnam 'test' )[ 1 ];
>
> my $encrypted_string = crypt $string, $pass;

Great! the above works! John your correction works!

Thanks Chas your perldoc helped out a lot as well.

>
>
>> print qq~
>> "$string" encrypted using the perl crypt() function and salt "$salt"
>> returns:
>> $encrypted_string  $pass
>> ~;
>
>
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you can special-order
> certain sorts of tools at low cost and in short order.       -- Larry Wall
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>

thanks again,

jerry


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to