the script then generates a 20-character session ID, encrypts it using Perl's built-in crypt() function

Already noticed that if two session ID's are different by only the last few characters, I get the exact same encrypted value

Note that crypt will only handle passwords up to 8 characters long. I guess you could follow other Monks advice and use use something like Digest::SHA1. This code

use strict; use warnings; my $salt = q{zy}; my $passwd = q{}; for ( q{a} .. q{m} ) { $passwd .= $_; my $encrypted = crypt $passwd, $salt; printf qq{%-3s%-15s%13s\n}, $salt, $passwd, $encrypted; }

produces

zy a zysdihJ0gvwVY zy ab zy4zYYneKaYuc zy abc zyVTopNmDAhDM zy abcd zyaO8uXTZHk.Q zy abcde zyIALca4k5yc2 zy abcdef zyTUr1c/J9ROc zy abcdefg zyB0MLdTVOSYY zy abcdefgh zyQskE0hBAgLs zy abcdefghi zyQskE0hBAgLs zy abcdefghij zyQskE0hBAgLs zy abcdefghijk zyQskE0hBAgLs zy abcdefghijkl zyQskE0hBAgLs zy abcdefghijklm zyQskE0hBAgLs

which demonstrates that crypt just discards anything beyond the 8th character.

I hope this is of interest.

Cheers,

JohnGG


In reply to Re: Using crypt for 'reasonably' secure session management w/DB by johngg
in thread Using crypt for 'reasonably' secure session management w/DB by punch_card_don

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.