In general this code is bad practice...
PHP Code:
<?php
mysql_query("INSERT INTO table (Password) VALUES ('".md5('$_POST['Password']')."')");
?>
... eventhough it works fine here without having the risk of sql injection as the
unverified userinput ($_POST['Password']) is hashed before inserted.
But the selection is missing in this insert statement, in this case the primary key to identify the user who want's to set the pw.
If you are interested in verifying the pw strength (nr of chars, occurence of upper/lowercase letters, spechial chars, numbers...) on serverside I'd transport the pw cleartext from client to server.
If it's ok for you, to do that on clientside via Javascript, I'd do the md5 (or better sha1 / sha256) hash sum on the client and just transport it to the server. Thus an attacker (MITM) won't see the pw on a clear text transportation (in case of no httpS use) and you only need to verify that returned string contains a specific length (eg. 32 chars with MD5) and numbers and letters (A-F), only.
I'd also salt the hash instead of using the plain hash, to defend the pw in the database against rainbow table attacks.
Keep in mind that hashing != encrypting, as a hash can not be "unhashed" (but it might be found in rainbow tables if not salted).
Recent comments
1 day 1 hour ago
1 day 7 hours ago
1 day 11 hours ago
1 day 13 hours ago
1 day 21 hours ago
2 days 7 hours ago
2 days 7 hours ago
2 days 11 hours ago
2 days 15 hours ago
2 days 16 hours ago