ryanfilard Posted June 19, 2011 Share Posted June 19, 2011 How would I encrypt the password and encrypt all the old users passwords too? Here is part of my code. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO users (fname, username, password, email) VALUES (%s, %s, %s, %s)", GetSQLValueString($_POST['fname'], "text"), GetSQLValueString($_POST['Username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['email'], "text")); Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/ Share on other sites More sharing options...
fugix Posted June 19, 2011 Share Posted June 19, 2011 To alter passwords that are already in your database, you will need to use an ALTER TABLE statement. As fir the encryption of new passwords bring entered into your db, what type of encryption are you looking to use? Salt, sha1, hash, md5 etc Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231819 Share on other sites More sharing options...
ryanfilard Posted June 19, 2011 Author Share Posted June 19, 2011 md5 Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231829 Share on other sites More sharing options...
redixx Posted June 19, 2011 Share Posted June 19, 2011 md5 MD5 is hashing not encrypting. And you should avoid it like the plague. See this topic: http://www.phpfreaks.com/forums/index.php?topic=336473.0 Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231831 Share on other sites More sharing options...
ryanfilard Posted June 19, 2011 Author Share Posted June 19, 2011 I will use salt Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231840 Share on other sites More sharing options...
redixx Posted June 19, 2011 Share Posted June 19, 2011 Even if you use salts, md5 is not a safe option. At the very very least, use sha1 instead (which has exactly the same usage as md5, so there's no excuses). Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231848 Share on other sites More sharing options...
ryanfilard Posted June 19, 2011 Author Share Posted June 19, 2011 alright Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231854 Share on other sites More sharing options...
fugix Posted June 19, 2011 Share Posted June 19, 2011 You'll want to use the sha1() function before insertion into your database. Since sha1 is 160, and depending on how many bits pwr character, would effect the length of the value, 20 or 40. So I recommend using BINARY(20) and the UNHEX function to convert the SHA1 value to binary. Quote Link to comment https://forums.phpfreaks.com/topic/239801-encrypt-password/#findComment-1231863 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.