PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 17th, 2000, 06:31 PM
tim miller tim miller is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12 tim miller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi.
I was having trouble emailing an encrypted password. The password is stored with the password option so it gets encrypted. I then lookup the password and email it using php3, but the password shows as encrypted. How do you decrypt it? I tried playing with the decrypt command but with no luck.
Any help is appreciated.
Tim

Reply With Quote
  #2  
Old January 18th, 2000, 08:16 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
Are you using MySQL's password() function to encrypt the password? If so, I don't believe you'll be able to decrypt it for obvious security reasons. Try using PHP's encrypt() function before storing it in the database and use the complementary PHP decrypt() function when pulling it out of the database.

Reply With Quote
  #3  
Old January 18th, 2000, 11:33 AM
tim miller tim miller is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12 tim miller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Originally posted by Kyuzo:
[B]Are you using MySQL's password() function to encrypt the password? If so, I don't believe you'll be able to decrypt it for obvious security reasons. Try using PHP's encrypt() function before storing it in the database and use the complementary PHP decrypt() function when pulling it out of the database.[/B

What is the purpose of the MySQL's password function if you can not ever decrypt it?

Reply With Quote
  #4  
Old January 18th, 2000, 11:40 AM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
From the MySQL manual...

PASSWORD(str)
Calculates a password string from the plaintext password str. This is the function that is used for encrypting MySQL
passwords for storage in the Password column of the user grant table.

mysql> select PASSWORD('badpwd');
-> '7f84554057dd964b'

PASSWORD() encryption is non-reversible. PASSWORD() does not perform password encryption in the same way that
Unix passwords are encrypted. You should not assume that if your Unix password and your MySQL password are the
same, PASSWORD() will result in the same encrypted value as is stored in the Unix password file. See ENCRYPT().

If you could decrypt this, you might be able to decrypt user passwords from the mysql db.

Reply With Quote
  #5  
Old January 18th, 2000, 12:08 PM
tim miller tim miller is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12 tim miller User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, that makes a lot of sense.

I am using trying to write a php file that will email the user their password if they forgot it. It goes along with Neoboard message board. I looked and they encrypt it like this:
$userpassword = crypt($userpassword,'.v');

I tried to decript it like this:
$userpassword2 = (decrypt($userpassword,'.v'));

And got this error:

Fatal error: Call to unsupported or undefined function decrypt() in /export/home/dmiller/public_html/neoboard/forgot2.php3 on line 54

Any suggestions?
Thanks again


Reply With Quote
  #6  
Old January 18th, 2000, 02:14 PM
Kyuzo Kyuzo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113 Kyuzo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
crypt() uses a one-way algorithm that can't be decrypted anyway, so it wouldn't have mattered. I checked a PHP book that I had and it spoke of encrypt() and decrypt() being complementary pairs but I did a small test and got the same error you did "unsupported function...blah blah.."

Another alternative - use MySQL's encode() and decode() functions for storing and retrieving, respectively. The key is that the column must be a blob type for holding binary data which is what is returned from the encode function.

Quick example.....

one column table with pass as blob type

%insert into table values(encode('captain', 'kangaroo')); // captain is actual password and kangaroo is the password string

%select decode(pass, 'kangaroo') from table

hope it helps

Kyuzo

Reply With Quote
  #7  
Old February 27th, 2000, 03:19 AM
amodi amodi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Gorakhpur,U.P.,India
Posts: 24 amodi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In continuation to this interesting discussion i would like to know whether it is possible to encrypt a string on the client side using JavaScript and decrypt it on the server side using PHP.

Pls Help...

Thanks in advance..



------------------
Anish Modi
Infotech World
India

Reply With Quote
  #8  
Old February 28th, 2000, 01:48 PM
jodonnell jodonnell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14 jodonnell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jodonnell
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by tim miller:
<snip>

I am using trying to write a php file that will email the user their password if they forgot it. It goes along with Neoboard message board. <snip>
[/quote]

Tim,

Typically, unless you have a reason to access the user's account AS THE USER, it is not really desirable for you to store the password at all. When a user forgets his or her password, I typically generate a brand new one for them and reset their old password password using an account with appropriate grants. You will find this to be generally more secure and carry lower overhead.

Best regards,

Jim


Reply With Quote
  #9  
Old February 28th, 2000, 01:57 PM
jodonnell jodonnell is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14 jodonnell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to jodonnell
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by amodi:
In continuation to this interesting discussion i would like to know whether it is possible to encrypt a string on the client side using JavaScript and decrypt it on the server side using PHP.

Pls Help...

Thanks in advance..


[/quote]

What are you using to encrypt on the Java side? If you are using JCE 1.2, it shares encryption methods with the m_crypt library in php. Haven't tried what you're doing, but if the methods are implemented correctly and you're using the same keys, you should not have a problem.

Additionally, I believe there are PGP encryption routines available for both PHP and java. You can send your public key for encryption and unencrypt using a private key which you control. This may be a good alternative for you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > mailing a encrypted password

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap