The only legitimate reason for doing this would be to return to the user their password if they've forgotten it. Because it's impossible, you are better off creating a new random password and emailing them.

Nefarious people don't nessarily have to brute force the actual password - they just need to find a hashing collision. i.e. if password "foo" and "bar" both hash to "abc", then they are identical as far as the password check goes. This may not seem like much of a distinction (especially as the hash is often longer, and the input salted), but it means if the hash algorithm is weak, then it can be exploited. I believe there has been some preliminary weakness in SHA (some researchers suggest that it could be cracked in, say, 75 years rather than 100 years), but overall they appear strong.

And if you allow passwords of length less than 1..

sub decrypt { my $crypted = shift; my $str = ""; foreach my $s1 (0 .. 255) { my $str = $str . chr $s1; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s2 (0 .. 255) { my $str = $str . chr $s2; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s3 (0 .. 255) { my $str = $str . chr $3; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s4 (0 .. 255) { my $str = $str . chr $4; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s5 (0 .. 255) { my $str = $str . chr $5; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s6 (0 .. 255) { my $str = $str . chr $6; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s7 (0 .. 255) { my $str = $str . chr $7; if ($cryped eq crypt($str, $crypted)) { return $str } foreach my $s8 (0 .. 255) { my $str = $str . $chr $8; if ($cryped eq crypt($str, $crypted)) { return $str } } } } } } } } } }

In reply to Re^2: gettin back crypted password by spongeboy
in thread gettin back crypted password by Anonymous Monk

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.