Eew. For each password, you tie a list of words using Tie::File at least twice - only to extract a single word each time. In order to do so, you have to read the entire file (if only to determine the number of lines). And you recurse if the word you pick is too long. While you'll save some memory, this isn't going to be efficient. I'd write select_a_word as:
my @words; INIT { open my $wh, "<", "/usr/share/dict/linux.words" or die; @words = grep {6 > length} <$wh>; close $wh or die; } sub select_a_word {lc $words[rand @words]}
But then, I wouldn't use your snippet, if only for the fact it can generate passwords not longer than 5 characters. Your number of possible salts is also low, 676 instead of the 4096 possibilities most systems allow for.

Finally, I'd use 'crypt' to generate both sets of passwords, as my system knows whether to use DES or MD5 based on the salt being used. (DES takes a 2 character salt, MD5 an 8 character salt, preceeded with '$1$', and (optionally) followed by a '$', giving 11 or 12 characters to pass into 'crypt'). But not every system will do so.

Perl --((8:>*

In reply to Re: Creating random passwords for users. by Perl Mouse
in thread Creating random passwords for users. by blue_cowdawg

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.