in reply to Problem using Digest::MD5
The code posted works perfectly here with Perl 5.6.1. It sounds as if the module is not installed. I would expect you would find the .pm file at d:/Perl/site/lib/Digest/MD5.pm. Is this the case? If so, you will find the loadable file (a DLL) at d:/Perl/site/lib/auto/Digest/MD5.dll. If this is not the case then I'd say your installation is a bit broken.
A few points about the code: "%ENV" will not interpolate. You want to do something like join( '', %ENV ). A second problem is that rand(500) doesn't give you much randomness, a shade under 9 bits. You want to generate at least 128 bits of randomness. Try something like:
my $x; $x .= chr(rand(255)) for 1 .. 16; # or more
This, of course, is only as good as your random number generator, but that's another story.
b64digest is a more compact representation of the digest than hexdigest, which might be useful since I imagine you are trying to generate session IDs. But hey, in that case, why not use something that has already been written, and, as a free bonus, has been scrutinised by a cast of thousands, namely Apache::Session.
|
|---|