logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > General
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 09-10-2007, 03:19 AM   #1
owner
 
Join Date: Sep 2007
Posts: 64
Default

how can you encrypt a users password so in the database it doesnt show the users exact password.
owner is offline   Reply With Quote
Old 09-10-2007, 07:03 AM   #2
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

ok

you can do this in a number of ways.

i use md5() which is a standard algorithm and used widely. It will return a 32 char hash of anything you process with it from a 5 char password to a whole 30 page text file.

try it...

PHP Code:
$string "dreamweaverclub"//<<< try anything you want in here and at any length
 
echo md5($string); 
ok

when setting up users you need to wrap your $password var in this function

PHP Code:
$password md5($password); 
you need to do this before you insert into the db and make sure you have your password field length set to 32 varchars.

you need to also compare md5 when logging in...

PHP Code:
$password md5($_POST['password']);
 
if (
$password == $row['password']){
//let me in

you cant decrypt an md5 string but you dont need to.
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-10-2007, 01:27 PM   #3
owner
 
Join Date: Sep 2007
Posts: 64
Default

Thank you, I will give this a shot.

Also, I could barely find this topic :P
owner is offline   Reply With Quote
Old 09-10-2007, 01:29 PM   #4
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

sorry

had to split the thread down as it could become confusing

try creating separate posts for different questions
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-10-2007, 01:34 PM   #5
owner
 
Join Date: Sep 2007
Posts: 64
Default

sorry, I didnt want to be clogging up the forums with a bunch of random questions.

I have a question though. Right now I have an account with a normal password. How can I change that from the normal password to the new md5 encrypted password in the database?
owner is offline   Reply With Quote
Old 09-10-2007, 01:57 PM   #6
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

you will have to manually change these

md5 the password and cut & paste the string into your db then build the md5 functionality into your admin account creation page
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-10-2007, 02:04 PM   #7
davidj
davidj's Avatar
 
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256
Default

Quote:
sorry, I didnt want to be clogging up the forums with a bunch of random questions.
err thats all this forum contains

dont worry you dont get charged for the questions you ask so ask away

its refreshing dealing with coders
__________________
Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote
Old 09-11-2007, 12:03 AM   #8
owner
 
Join Date: Sep 2007
Posts: 64
Default

Cool! I got this working! Thank you very much! This should be a little more secure now
owner is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:02 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com