I have a jquery dialog modal box pop up for logging into my website. When a user clicks login it does a post request to a login.php file as follows:
$.post( 'includes/login.php', { user: username, pass: password }, onLogin, 'json' );
How do I do an md5 on that password before putting it in the post request? Also, I have the user's passwords stored in a MySQL database using MD5(), so I would like to just compare the stored version of the password with the MD5 of the password submitted. Thanks to anyone that replies.
How to Validate an MD5 Hash in JavaScript. If you just want to check if a hash is correct for a string, it's easy. Just hash the string with the MD5 algorithm and see if it matches the hash code you are testing.
Unfortunately, MD5 has been cryptographically broken and considered insecure. For this reason, it should not be used for anything. Instead, developers should switch to the Secure Hash Algorithm or a Symmetric Cryptographic Algorithm.
MD5 is a standardized 1-way function that allows any data input to be mapped to a fixed-size output string, no matter how large or small the input string is. A small change in the input drastically changes the output.
The MD5 message-digest algorithm is a cryptographically broken but still widely used hash function producing a 128-bit hash value. Although MD5 was initially designed to be used as a cryptographic hash function, it has been found to suffer from extensive vulnerabilities.
crypto-js is a rich javascript library containing many cryptography algorithms.
All you have to do is just call CryptoJS.MD5(password)
$.post( 'includes/login.php', { user: username, pass: CryptoJS.MD5(password) }, onLogin, 'json' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With