The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
mailing a encrypted password
Discuss mailing a encrypted password in the PHP Development forum on Dev Shed. mailing a encrypted password PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 17th, 2000, 06:31 PM
|
|
Junior Member
|
|
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12
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
|

January 18th, 2000, 08:16 AM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113
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.
|

January 18th, 2000, 11:33 AM
|
|
Junior Member
|
|
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12
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?
|

January 18th, 2000, 11:40 AM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113
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.
|

January 18th, 2000, 12:08 PM
|
|
Junior Member
|
|
Join Date: Jan 2000
Location: Hillsboro, OR, USA
Posts: 12
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
|

January 18th, 2000, 02:14 PM
|
|
Contributing User
|
|
Join Date: Oct 1999
Location: Annapolis, Maryland US
Posts: 113
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
|

February 27th, 2000, 03:19 AM
|
|
Junior Member
|
|
Join Date: Jan 2000
Location: Gorakhpur,U.P.,India
Posts: 24
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
|

February 28th, 2000, 01:48 PM
|
|
Junior Member
|
|
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
<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
|

February 28th, 2000, 01:57 PM
|
|
Junior Member
|
|
Join Date: Feb 2000
Location: durham, nc, usa
Posts: 14
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
<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.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
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
|
|
|
|
|