Monday, August 1, 2011

MD5 encryption and decryption

Today a friend needed to decrypt a password which was encrypted using md5 algorithm. So I got an anxiety to study more about it.

Here is some information that I have gathered about it

  1. MD5 is a secure hash algorithm. It takes a string as input, and produces a 128-bit number, the hash.
  2. The same string always produces the same hash, but given a hash, it is not generally possible to determine the original string.
  3. Secure hash algorithms are useful for protecting passwords and ensuring data integrity

Now, I wanted to know, how do I use it with my web-applications. Thank God there are inbuilt libraries of JQuery that provides support.
You can get jQuery and jquery.md5.js from the following links : jQuery.js and jQuery.md5.js

This example might be a very basic level of encryption of md5.
There are various more secure encryptions available for md5, but at this point in time, I have this much understanding.

Example HTML :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MD5 Encryption Example</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.md5.js"></script>

<script type="text/javascript">
function chn(){
 var a = document.getElementById('txt1');
 var b = document.getElementById('txt2');
 var c= a.value;
 
 var d = $.md5(c);
 b.value = (d);
}

</script>

</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <label>
    <input type="text" name="jh" id="txt1"  onblur="chn();"/>
  </label>
  <label>
    <input type="text" name="q" id="txt2" />
  </label>
</form>
</body>
</html>


4 comments:

  1. whart about decryption??

    ReplyDelete
    Replies
    1. drcryption doesnt have any method as encryption. only thing they do is store whatever string u encrypt from their website and return it to you when u ask for it

      Delete
    2. drcryption doesnt have any method as encryption. only thing they do is store whatever string u encrypt from their website and return it to you when u ask for it

      Delete