Password encoding/decoding function (Expert PHP)

09-12-09, 09:59 PM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Password encoding/decoding function (Expert PHP)
Hello every body,
I'm Hassan Faghihi (Know as deadManN), and i and some of my friend are about to make a platform, but there's some problem, we have to link our user from client to our forum database, but there's a mess in DB, cuz all data has been coded, and my need is a structure that be enable to decode the the data, but it's a hard for me to trace PHP, even though i don't know any about that.
the forum i need you trace for me is DIscuz Ver 6.1. that you can download from E-Discuz.com
in DB out table is cdb_members and in forum i need both register and read user, so we need to trace the structure from Register and from login .
Please help me ASAP,
I looking after you guys, as i told you i don't know any about PHP else i do this myself.
Thank you,
deadManN.
|

09-13-09, 09:20 AM
|
 |
Level II Curmudgeon
|
|
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 34 Times in 33 Posts
|
|
Hmmm....from the Dizcuz download page:
"We have translated and moded this Discuz! 6.1 to make more stable because , maybe you already know , Discuz! 6.0 is very easy to hack ."
That's not exactly what I'd call an auspicious beginning.....
Anyway, I went there to see if I could get a a copy and help you out, but I must be an idiot because I didn't see any place I could actually download the code from. Lots and lots of messages about downloading the code, but I must have missed the link where you actually get it.
Homepage >> Download Latest Discuz now ! >> ??????????
Post the code or a zip and I'll see what I can do.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
|

09-13-09, 10:38 AM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
|

09-13-09, 04:45 PM
|
 |
Level II Curmudgeon
|
|
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 34 Times in 33 Posts
|
|
I looked at this and what they do is store the MD5'd user password along with a random salt. Here's the code snippet that does that:
$salt = random(6);
$password = md5(md5($password).$salt);
First they create a random salt, then they append the salt to the password and MD5 it, then they MD5 the result again. Finally they do the insert into the DB, storing the salt:
INSERT INTO {$tablepre}members (username, password, salt, ..... etc
You can't really "undo" an MD5 function, but by using the same function with the stored salt value, you could create the same MD5 digest of the password for use in your system. The user could then login with the same password
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
|

09-14-09, 09:42 AM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
so can i have this md5 function also plus salt in other language?
|

09-14-09, 04:12 PM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Also, how they have been combined?
like attach random number in front or end of code, or like encode or decode via number 5?!
|

09-14-09, 07:50 PM
|
 |
Level II Curmudgeon
|
|
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 34 Times in 33 Posts
|
|
Quote:
Originally Posted by deadManN
so can i have this md5 function also plus salt in other language?
|
You can have it in any language you want, as far as I know. (You'll want to use same they salt they generate so the MD5 result comes out the same.)
Quote:
Originally Posted by deadManN
Also, how they have been combined?
like attach random number in front or end of code, or like encode or decode via number 5?!
|
Please try reading my post- I showed you the exact code they use, right there in my post, plus I explained it in detail.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
|

09-15-09, 12:45 AM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok, what about decoding?! don't we need to separate salt, or actually we use the number again to decode, and in the end we just have our password , include nothing more !
|

09-15-09, 01:57 AM
|
|
Newbie Coder
|
|
Join Date: Jul 2009
Posts: 24
Thanks: 0
Thanked 1 Time in 1 Post
|
|
You are not able to get the passwords out of the hashes.
If you want existing user to be able to log in, you will have to implement the current logic in your project.
End User was so kind to look it up for you:
$password = md5(md5($password).$salt);
All you need to do is:
Have access to the 'old' user-data (You`ll need the username, password, salt Fields from {$tablepre}members).
When someone tries to log in, check if that login exists.
if it does, get the salt and password-hash to that login out of the database.
check if
$database_password_hash == md5(md5($user_entered_password).$database_salt)
|

09-15-09, 05:46 PM
|
|
Newbie Coder
|
|
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
tnx, and just one more thing, if my project be based on java, what diff will be on this code, what i need to include, and how to make this on there?
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|