Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use MD5 in javascript to transmit a password

Tags:

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.

like image 569
adhanlon Avatar asked Dec 26 '09 00:12

adhanlon


People also ask

How do I use MD5 in JavaScript?

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.

Is MD5 good for password hashing?

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.

What is MD5 hash JavaScript?

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.

Is MD5 Crackable?

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.


1 Answers

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' ); 
like image 61
James Skidmore Avatar answered Oct 20 '22 16:10

James Skidmore