Current location: Hot Scripts Forums » Programming Languages » PHP » Forgot Password MD5


Forgot Password MD5

Reply
  #1 (permalink)  
Old 07-10-06, 08:58 PM
adubb adubb is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Forgot Password MD5

Does anyone know a good method for setting up a forgot password page? I am using MD5 as my password encryption now im kinda stumped to a secure way of reversing this

Whats the most common way? Is there any examples available on HS.com?

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-10-06, 09:04 PM
stormshadow's Avatar
stormshadow stormshadow is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 355
Thanks: 0
Thanked 0 Times in 0 Posts
cannot be done..

at least i dont think so.. the only way i would tell you is.. to reset their password to a random string containing letters and numbers...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-10-06, 09:09 PM
adubb adubb is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
StormShadow, check your PM for old stuff we discuessed awhile ago
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-10-06, 11:36 PM
1jetsam 1jetsam is offline
Wannabe Coder
 
Join Date: Apr 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
You're not suppose to be able to reverse the md5 encryption. It's meant for one way encryption. The only thing you can do is assign a new password. I guess the hard part is how to make this process a secure process.

I'd do it like this: The user requests a new password (because the user forgot their password) by giving their username. An email is sent to the email address of the username that was given, saying "Someone has requested a new password for _username_. To continue, go to: http://website.tld/forgot.php?code=3d4fke" The 3d4fke code is saved, so that when the user comes to the site again with that code (which is already in the url), a new password will finally be issued. There. Simple and secure.
__________________
Quate CMS 0.3.3 Released - A simple, fast Content Management System.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-12-06, 10:58 AM
Acecool's Avatar
Acecool Acecool is offline
Aspiring Coder
 
Join Date: Nov 2003
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
Create a table

id
userid
auth
password

so

1 - 1 - x392löxskeiw - 12345678901234567890123456789012
id user the auth pass...

Once they reqeust they forgot the password, it will set an auth code into the database, this will be for the link, you will pregenerate the password and email it to them, once they click the link the password will work... move the md5 over to the user table.. :-)
__________________
Check Acecoolco.com for PHP Tutorials, and other tuts
If you plan on contacting me, please read this: Legal Terms & Conditions
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 07-12-06, 03:04 PM
NabZ NabZ is offline
Newbie Coder
 
Join Date: Nov 2005
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
I would advise the above, but if you are in real need to reverse, try the following sites.

http://www.plain-text.info
http://milw0rm.com
http://md5.crysm.net
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 07-14-06, 06:52 PM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
I know this is a bit late to bring this up, but I thought it would be interesting to note that you do not have to add an additional field for lost passwords. Instead, you can do it entirely with code if you prefer based on old hash and even automatically expiring.

For example:
PHP Code:

<?php


function generateLostPasswordHash($current_pass_hash)
{
    
// generate time based on day
    
$dayTime mktime(000);

    
// generate lost password hash based on some hard coded phrase or key, current day's time, and current hash
    
$lostPassHash md5("some random static key" $dayTime $current_pass_hash);
    
    
// return only portion of hash, starting at character 8 (position starts at 0) and providing 12 characters
    
return substr($lostPassHash712);
}

/**
*    $current_pass_hash = user's db pass hash
*    $lost_pass_hash = 12 character has provided by user that we generated for them above
*/
function checkLostPasswordHash($current_pass_hash$lost_pass_hash)
{
    
// generate time based on day
    
$dayTime mktime(000);
    
    
// generate time based on yesterday (quick and dirty way... you could change this)
    // 86400 = # seconds / day (60*60*24)
    
$yesterdayTime $dayTime 86400;

    
    
// generate pass hash based on today
    
$dayLostPassHash substr(md5("some random static key" $dayTime $current_pass_hash), 712);
    
    
// generate pass hash based on yesterday
    
$yesterdayLostPassHash substr(md5("some random static key" $yesterdayTime $current_pass_hash), 712);

    
// if user's pass hash matches today's or yesterday's hash
    
if ($lost_pass_hash == $dayLostPassHash || $lost_pass_hash == $yesterdayLostPassHash)
    {
        
// let user choose new pass or whatever...
    
}
    else
    {
        die(
"Lost Password Request Expired or Invalid.");
    }
}
The method above is fairly secure. We generate a hash that automatically expires based on time (between 24-48 hours) without the need to store the generated hash into a database. In other words, we generate a hash based on old hash, time, and some static string. We then provide the user with a portion of that hash via email. We then validate the portion of the hash that the user provides by generating it on the server (again) using old hash, time, and some static string. By checking against two times (today / yesterday), you give the hash somewhere between 24-48 hours to be used (depending on server time when it was generated).

Anyway, I thought I would post it as it is a different approach.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 07-14-06, 07:54 PM
twoeyes twoeyes is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
To clarify MD5 is not an encryption method, its a hash so there is no going back once you reverse it. IMHO you should have the forgot password button do the following:

- user clicks i forgot password
- enters their username and/or/maybe email
- gets emailed a link
- on the page gets to reset the password

you'll need a database or something to keep track of valid links. also would suggest a timeout period.
__________________
there are 10 types of people in the world, those who know binary and those who dont
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare 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
md5 issue tophat PHP 8 06-30-06 10:08 AM
Password Problems in VB6 iceiceady Visual Basic 6 03-28-06 04:17 PM
Password not going through FiRe Visual Basic 2 12-02-04 10:53 AM
forgot password help mathieu67 PHP 4 10-13-04 11:43 PM


All times are GMT -5. The time now is 08:47 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.