Rohit Nirmal
The MD4, MD5 and SHA-1 algorithms are all secure functions. They take a string as input and produce a fixed size number, 128 bits for MD4 and MD5, and 160 bits for SHA-1. This number is a hash of the input which means that a small change in the input results in a substantial change in the output number.
It is the characteristic of hash function that it is almost impossible to determine the string from its hash, while it is very easy to compute the hash of any string.
So, these functions are considered secure meaning that it requiers an enormous amount of computing power and time to find a string that hashes to a chosen value. In other words there is no way to decrypt a secure hash.
Secure hashes are used in digital signatures and challenge hash authentication.
You can download free Javascript implementations of all three alogorithms from sites on the web.
calcMD5("hello") = "5d41402abc4b2a76b9719d911017c592"
calcMD4("hello") = "866437cb7a794bce2b727acc0362ee27"
calcSHA1("hello") = "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
Now try changing your input string to "gello". You will get the following result:
calcMD5("gello") = "eebc55db607dc752a7c115e1a3e2e3ff"
So, we found that a small change in the input resulted in a huge change in the output number.
Let us suppose that we have decided that the password will be "encrypt". So, you use the facility given above to find MD5 hash of "encrypt". It comes to "53c82eba31f6d416f331de9162ebe997". So, in the Javascript code on this page in method "verify()" I am comparing the hash of the string entered by the user with "53c82eba31f6d416f331de9162ebe997". If they are equal this means that the user entered the correct password, and we poup a window with text "Great! You have entered a valid password!".
Note that we have mentioned the word "encrypt" above. But on a real log-in form the password in clear form will not be mentioned either on the page or in the Javascript code on the page.
The user can display the source of the page and find that we are comparing a string to "53c82eba31f6d416f331de9162ebe997" but from this string he can not retrieve the password.
However, you must understand that one caveat with using Javascript cryptography is that it only protects you against passive eavesdropping. A malicious attacker who can modify network traffic can intercept the transmission of the Javascript code and replace it with code that does not verify the password entered and lets the user go ahead with using the system as if he entered the correct password.
** The End **