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.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: Problem using Digest::MD5 by grinder
in thread Problem using Digest::MD5 by Tim_Odom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.