If you wants to store the passwords in a mysql database for an application, the following remark from the mysql manual is maybe relevant:

quote (13.8.2 Encryption Functions: PASSWORD(str)):

Note: The PASSWORD() function is used by the authentication system in MySQL Server, you should not use it in your own applications. For that purpose, use MD5() or SHA1() instead. Also see RFC 2195 for more information about handling passwords and authentication securely in your application.

A better practice is to calculate the SHA1 or MD5 sum of the password and store the results in your database

Both functions, MD5 and SHA1, are one way hash functions. So you can't reverse them to obtain the original 'clear' password.

To authenticate somebody, just recalculate the SHA1 or MD5 sum of the given password in your application using module "Digest::SHA1" or "Digest::MD5". Then query the databank with a simple select statement to check if the calculated MD5/SHA1 value matches the stored value MD5/SHA1 for the user in the database. In that way the password is never send in clear from your application to the database.


In reply to Re: Reversing MySQL's password function by martell
in thread Reversing MySQL's password function by ralijani

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.