|
Posted by Greg G on May 10, 2005, 5:31 pm
Please log in for more thread options
Jim Gibson wrote:
>
>
>>This is really bizzaro. Here's my code:
>>
>>use Digest::SHA1;
>>
>>$password = "garbage";
>>my $ctx = Digest::SHA1->new;
>>$ctx->add($password);
>>my $encpw = "" . $ctx->b64digest . "=";
>>print STDERR "" . $ctx->b64digest . "=\n";
>>print STDERR "$encpw\n";
>>print STDERR "" . ($ctx->b64digest) . "=\n";
>>
>>But here's the output:
>>
>>2jmj7l5rSw0yVb/vlWAYkK/YBwk=
>>eMZ8EmV1wgxrRoRHNV6b0g0iEgI=
>>2jmj7l5rSw0yVb/vlWAYkK/YBwk=
>>
>>
>>What gives here? Why are these different? Incidentally, the $encpw one
>>is the correct one.
>
>
> Did you read the documentation for Digest::SHA1?
I hadn't. That does indeed explain what I'm seeing. { D'OH! }
Thanks.
> $sha1->b64digest
> Same as $sha1->digest, but will return the digest as a base64
> encoded string.
>
> Print the values using $ctx->clone->b64digest and they will be the same.
-Greg G
|