joeysarsenal Posted October 17, 2007 Share Posted October 17, 2007 Is there a way to add encripted passwords (md5) on the table fiel so that there are any passwords typed into that field its automatically encripted if there isnt a way how may i go about doing this. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/ Share on other sites More sharing options...
~n[EO]n~ Posted October 17, 2007 Share Posted October 17, 2007 $password = md5($_POST['pwd']); and save the $password in the table... Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371406 Share on other sites More sharing options...
joeysarsenal Posted October 17, 2007 Author Share Posted October 17, 2007 How can i add that to table structer like create table member `member_id int(11) unsigned NOT NULL primary key auto_increment, `password varchar(32) not null, would it then become `password .md5(20) not null. sorry im quiet new :S Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371407 Share on other sites More sharing options...
~n[EO]n~ Posted October 17, 2007 Share Posted October 17, 2007 Is it possible ??? I don't think so... search google I found this maybe it will help you http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html AES_DECRYPT() Decrypt using AES AES_ENCRYPT() Encrypt using AES Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371415 Share on other sites More sharing options...
joeysarsenal Posted October 17, 2007 Author Share Posted October 17, 2007 well how can i go about adding many .md5 passwords into one table my code is as use plaincart; # # Table structure for table 'members' # CREATE TABLE `members` ( `member_id` int(11) unsigned NOT NULL auto_increment, `firstname` varchar(100) default NULL, `lastname` varchar(100) default NULL, `email` varchar(100) NOT NULL, `city` varchar(100) NOT NULL, `address` varchar(100) NOT NULL, `postcode` varchar(100) NOT NULL, `login` varchar(100) NOT NULL default '', `passwd` varchar(32) NOT NULL default '', PRIMARY KEY (`member_id`) ) TYPE=MyISAM; # # Dumping data for table 'members' Populating the table is below. <?php /* Populate The Staff Table ** Use an Include file to open the database */ include( "connect.inc" ); $sql = "DELETE FROM members"; //drop all data , then insert mysql_query($sql ); $sql = "INSERT INTO members VALUES " . "(NULL,'Joe','m','leboe@hotmail.com','mefsdflb','69 fook street city','4444','joe','joe'), " . "(NULL,'Joe1','m1','sdfdsdsf@hotmai1l.com','melfsdfb1','691 fook street city','4441','joe1','joe1')"; if(mysql_query($sql)){ echo("<p>client table successfully populated!</p>"); } else{ print("<p>Error adding to client table: " . mysql_error() . "</p>"); } ?> at the moment its just normal words but i want it encripted and if im going to add 50 user names and passwords i would like it encripted. I googled but no help. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371417 Share on other sites More sharing options...
~n[EO]n~ Posted October 17, 2007 Share Posted October 17, 2007 you can save your values in a variable, encrypt it and save it in db suppose your username is Joel then <?php $myuser = "Joel"; $myencrypteduser = md5($myuser); ///while you echo ///you will get this da64a1bc2c9a53dd1cdb6846103cd2de ?> and you can insert this $myencrypteduser in the database , Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371424 Share on other sites More sharing options...
joeysarsenal Posted October 17, 2007 Author Share Posted October 17, 2007 n~ link=topic=163904.msg718852#msg718852 date=1192613793] you can save your values in a variable, encrypt it and save it in db suppose your username is Joel then <?php $myuser = "Joel"; $myencrypteduser = md5($myuser); ///while you echo ///you will get this da64a1bc2c9a53dd1cdb6846103cd2de ?> and you can insert this $myencrypteduser in the database , wouldnt i have to set another variable for the username or password for instance like <?php $myuser = "password" $password = "Select From Members where password = $password" (Just taking a punt here) $myencrypteduser = md5($myuser); ///while you echo ///you will get this da64a1bc2c9a53dd1cdb6846103cd2de ?> Not sure if thats right but is there a way that it would grab the password field from the table. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371478 Share on other sites More sharing options...
joeysarsenal Posted October 17, 2007 Author Share Posted October 17, 2007 ok ive used neons md5 code. is there a way i can name mulitple variables for different passwords? <?php /* Populate The Staff Table ** Use an Include file to open the database */ include( "connect.inc" ); $sql = "DELETE FROM members"; //drop all data , then insert mysql_query($sql ); $pass = "password"; (Want more Variables here) $passwd = md5($pass); (Need to name alot more passwords). $sql = "INSERT INTO members VALUES " . "(NULL,'Joe','m','lebo_joe@hotmail.com','melb','69 fook street city','4444','joe','$passwd'), " . "(NULL,'Joe1','m1','lebo_joe@hotmai1l.com','melb1','691 fook street city','4441','joe1','joe1')"; if(mysql_query($sql)){ echo("<p>client table successfully populated!</p>"); } else{ print("<p>Error adding to client table: " . mysql_error() . "</p>"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371508 Share on other sites More sharing options...
fenway Posted October 17, 2007 Share Posted October 17, 2007 ok ive used neons md5 code. is there a way i can name mulitple variables for different passwords? Huh? Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-371538 Share on other sites More sharing options...
joeysarsenal Posted October 18, 2007 Author Share Posted October 18, 2007 well if i use the code he gave me i can only encript 1 password i want to encript a couple more. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-372017 Share on other sites More sharing options...
~n[EO]n~ Posted October 18, 2007 Share Posted October 18, 2007 You can use any number of variable $myuser = "Joel"; $myuser1 = "Joel1"; $myuser2 = "Joel2"; $myuser3 = "Joel3"; $myencrypteduser = md5($myuser); $myencrypteduser1 = md5($myuser1); $myencrypteduser2 = md5($myuser2); $myencrypteduser3 = md5($myuser3); like this and ok ive used neons md5 code. and md5 is not mine Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-372085 Share on other sites More sharing options...
joeysarsenal Posted October 19, 2007 Author Share Posted October 19, 2007 lol neon i know its not urs but u helped give me the code. Thanks thats what i wanted. Uve been really helpful i just thought if it would be possible to do something like this like it automatically checks the field were "passwd" is in my table and automatically encripts it. If i do it how i was before i have to encript every password and i don't know who's going to use what if there isnt a way ill just have to stick to this. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-372920 Share on other sites More sharing options...
fenway Posted October 19, 2007 Share Posted October 19, 2007 There is no such thing as an "MD5 column type" or equivalent -- nor should there be, because that would require sending the raw, plaintext value unencrypted to the DB... which is undesriable. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-373172 Share on other sites More sharing options...
Simon Moon Posted October 20, 2007 Share Posted October 20, 2007 Hash in PHP, then send to DB. $password = "test"; $passwordmd5 = md5($password); $query ="INSERT INTO table SET username='user', password='$passwordmd5'"; Or something to that extent. You can also use the MD5 function in the DB, but then you will transfer it in plain text. You are always better off to do the complicated parts in PHP when it comes to those things. Quote Link to comment https://forums.phpfreaks.com/topic/73615-adding-encripted-passwords/#findComment-373686 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.