As has already been stated, MD5 is a one-way algorithm. If you want something that can encode and decode as well, you may wish to look at Crypt::OpenSSL::AES.

Digests/Hashes vs [En|De]cryption Examples

MD5 and other one-way hashes/digests like the SHAs (Wikipedia link) can be used to store representations of passwords in a database. If some villain were to get into the database, they would not be able to see the passwords - only the digests. Validating the passwords would involve taking the password from the user, creating the hash/digest and comparing it with the hash/digest stored. But there is no way to get the original value back.

If, however, you wanted to store a string securely in a database but still be able to get back at the original value (such as if you were storing payment details, medical details, etcetera,) that is when you would use something like AES (Wikipedia link), which does encryption and decryption using a key. (Note that these digests don't use keys.)

Just for reference, if you are working with MySQL, functions md5(), sha1(), aes_encrypt() and aes_decrypt are built in (at least in versions 5.x,) so you have the option of doing these in the database if you don't want to do them in Perl. (Handy if you use stored procedures.) MySQL Encryption and Compression Functions refers.


In reply to Re: Is there any module which can convert the Digest MD5 encoded string back to plain text? by smiffy
in thread Is there any module which can convert the Digest MD5 encoded string back to plain text? by sanjay nayak

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.