If you are a learn-by-doing type, you can confirm for yourself that both htpasswd and Perl's crypt() are doing the same thing. Use htpasswd and then look at the resulting encrypted password. Then at the command line, paste that encrypted word as the seed into the following line (substituting your own values for "PassWord" and "htpasswdCrypted"): perl -e 'print crypt("PassWord", "htpasswdCrypted"), "\n"' Then chop off the first two characters of the encrypted password and do it again: perl -e 'print crypt("PassWord", "ht"), "\n"' In both cases, Perl should spit back the same encryption you obtained with htpasswd. Given a seed, crypt() uses the first two characters (ignoring the rest) and does its magic -- giving back the seed as the first two characters again so that the encrypted password carries its own seed.

You may need this capability later to authenticate a specific password if you are doing this under program control. On the other hand, Apache chooses a random seed for you and then later handles the authentication itself. No need to ask Apache to confirm a password from a given seed.

See crypt.


In reply to Re: crypt question by dvergin
in thread crypt question by fastkeys

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.