Current location: Hot Scripts Forums » Programming Languages » PHP » Password encoding/decoding function (Expert PHP)

Password encoding/decoding function (Expert PHP)

Reply
  #1 (permalink)  
Old 09-12-09, 09:59 PM
deadManN deadManN is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Question 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-13-09, 09:20 AM
End User's Avatar
End User End User is offline
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-13-09, 10:38 AM
deadManN deadManN is offline
Newbie Coder
 
Join Date: Sep 2009
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
here's link: Discuz! 6.1 Download English Translated by E-Discuz.com - General Discussion - Discuz! support forum discuz - Powered by Discuz! - Support by E-Discuz
u must post a reply, so it will show u !
BTW it's file link it host allow you: http://www.e-discuz.com/discuzdownlo...Discuz.com.zip

thank you for your help, but as i told you, i don't know php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-13-09, 04:45 PM
End User's Avatar
End User End User is offline
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-14-09, 09:42 AM
deadManN deadManN is offline
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-14-09, 04:12 PM
deadManN deadManN is offline
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?!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 09-14-09, 07:50 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,029
Thanks: 14
Thanked 34 Times in 33 Posts
Quote:
Originally Posted by deadManN View Post
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 View Post
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 09-15-09, 12:45 AM
deadManN deadManN is offline
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 !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 09-15-09, 01:57 AM
captcha captcha is offline
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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 09-15-09, 05:46 PM
deadManN deadManN is offline
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
advanced php function soloWebDev PHP 6 05-09-07 10:47 PM
PHP Security alert: PHP mail() Function Lets Remote Users Inject E-mail Headers darkerstar PHP 4 04-29-07 07:14 PM
Help with php mail function maverickminds PHP 2 08-03-06 11:51 PM
Interspire is looking for a highly motivated PHP expert 2 join our young dynamic team Interspire Job Offers & Assistance 0 06-16-05 06:38 PM
edit php in Squirrelmail jrcortrightiii PHP 1 07-10-03 02:08 PM


All times are GMT -5. The time now is 08:00 PM.
vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.