Current location: Hot Scripts Forums » Programming Languages » PHP » Getting Password


Getting Password

Reply
  #1 (permalink)  
Old 04-20-05, 04:55 PM
x3graphics x3graphics is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Getting Password

Hello everyone,
I am new to php/mysql and this forum. I have started to create a site with a user login, which has worked fine so far, but I am trying to create a script for when someone forgets their username or password for the site. When I try to select the password in my sql I get the hashed value. How do I get the actual password. I have been searching on the web to see if it is possible, but haven't come up with anything. If this isn't possible what is the best way to get around this.
Thank You,
x3graphics
Reply With Quote
  #2 (permalink)  
Old 04-20-05, 05:13 PM
djwayne_2004 djwayne_2004 is offline
Newbie Coder
 
Join Date: Jan 2005
Location: England
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Hi x3graphics,

Depends on how the passwords are encryped, if you could post the script here we can help you more. There are many methods that you could use to create a "forgot your password" script, try looking for one on Hotscripts if not then i can help you out.

Kind Regards

Wayne
Reply With Quote
  #3 (permalink)  
Old 04-20-05, 07:03 PM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
hi x3graphics,
maybe the password is stored in one way hash. if it's so, there's no such way to retrieve lost password. instead, you should make a page/section where user can ask for new password.
__________________
just an ignorant noob with moronic solution...
Reply With Quote
  #4 (permalink)  
Old 04-21-05, 02:53 AM
x3graphics x3graphics is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
I used the mysql password function. So I am guessing that it is a one way hash. I don't remember reading about only one way hashes, i figured that I would be able to bring the hashed value back to its original value. I guess I could just make the user reset the password. For future reference how would I create a password that would be a two way hash.
Thank you
x3graphics
Reply With Quote
  #5 (permalink)  
Old 04-21-05, 06:50 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
Go to your table and browse it, study the password field for each user. If its a load of random letters and numbers its most likely encrypted in md5 in which case for the lost password feature you have to create a random new password and encrypt it. If the passwords are not encrypted then you can just echo it, though its less secure if its not encrypted in the database. I recommend you take a look at http://www.xeweb.net/tutorials/user_...dex.php?page=6
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #6 (permalink)  
Old 04-21-05, 09:58 AM
moronovich moronovich is offline
Junior Code Guru
 
Join Date: Oct 2004
Posts: 460
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by x3graphics
I used the mysql password function. So I am guessing that it is a one way hash. I don't remember reading about only one way hashes, i figured that I would be able to bring the hashed value back to its original value. I guess I could just make the user reset the password. For future reference how would I create a password that would be a two way hash.
Thank you
x3graphics
mysql password is one way hash. if you want to use 2-way hash, you can try AES Rijndael 128-bit (symmetric encryption) or even RSA encryption (asymmetric encryption with private and public key)

link to mysql encryption functions http://dev.mysql.com/doc/mysql/en/en...functions.html

tips:
1. further reading: Bruce Schneier, Applied Cryptography
2. RTFM is the ultimate resource.

off topic:
The Da Vinci Code, a good novel to read..
__________________
just an ignorant noob with moronic solution...
Reply With Quote
  #7 (permalink)  
Old 04-21-05, 10:46 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
or use blowfish, i use it but u need PEAR 2 support it!
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #8 (permalink)  
Old 04-21-05, 12:46 PM
x3graphics x3graphics is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
So I am going to use this aes_encript function, but I am not sure how to use it. My previous sql command was:

insert into auth_user values ('','$_POST[f_name]','$_POST[l_name]','$_POST[user_name]', password('$_POST[user_pass]'),'$_POST[user_priv]','$_POST[email]', now(), now())"

Could someone PLEASE rewite it with the new fuction
Thank you
x3graphics
Reply With Quote
  #9 (permalink)  
Old 04-21-05, 01:09 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
instead of just $_POST[user_pass] use AES_ENCRYPT("some random long key", $_POST[user_pass])
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
  #10 (permalink)  
Old 04-21-05, 01:26 PM
x3graphics x3graphics is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
instead of just $_POST[user_pass] use AES_ENCRYPT("some random long key", $_POST[user_pass])
should the key be in single or double quotes? and how about the inputed password does that need to be in quotes?
Thank you
x3graphics
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
Password not going through FiRe Visual Basic 2 12-02-04 09:53 AM
looking for a shoping cart has a sign up form with username and password they choose. kicon Script Requests 1 11-03-04 11:15 AM
Need To Password Protect a Page For Multi-Users cebuy PHP 8 09-09-04 07:57 AM
password textbox mpriest HTML/XHTML/XML 14 07-07-04 09:56 AM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 12:00 PM


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