LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-01-2006, 11:10 PM   #1
DamianS
LQ Newbie
 
Registered: Sep 2006
Posts: 5

Rep: Reputation: 0
password and cookie encryption


I have been developing a site and login process using php and mysql.
It is now to the point where I want to encrypt cookies, but am unsure which way to go.
I have looked at mcrypt, but the last version on sourceforge is 3 years old.
Is it still safe to use mcrypt and libmcrypt?

I am currently encrypting passwords with md5 which I understand is actually a 1-way hash.
However, I would like to encrypt them such that it could be reversed so I can send back the user their password in an email, rather than generating a new password for them each time.
Is it really much of a security risk to do this?
(I will add salt to prevent dictionary attacks.)
 
Old 11-03-2006, 07:02 AM   #2
senyahnoj
Member
 
Registered: Jul 2004
Location: Gloucestershire, UK
Distribution: Ubuntu, Debian & Gentoo
Posts: 74

Rep: Reputation: 16
Well you will compromise on security a little using 2-way encryption but if that's the functionality you want then that's what you're best doing. The fact that passwords can ultimately be sent in email unencrypted is a security compromise in itself.

Like with any encryption, using several methods in combination and concatenating the password string with a secret key string known only to your application will make it increasingly more secure.

You can also think about storing the password in the database using a 2-way encryption method (like mcrypt), and using a different 1-way encryption method (e.g. md5) for the authentication cookie you send back to the client.

I can highly recommend the PHP Cookbook (O'Reilly) which is an excellent book and has a highly informative section with examples on encryption and decryption using mcrypt and doing cookie based authentication. Otherwise, check out the user-submitted recipes on the PHP manual http://uk.php.net/manual/en/ref.mcrypt.php

The other way is to keep one-way encryption and get the user to fill out a 'password reminder' field and store it in a database. You can email that to them instead of the password.

Last edited by senyahnoj; 11-03-2006 at 07:03 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Suse 9.3 Password encryption bratieres SUSE / openSUSE 2 10-10-2006 10:36 AM
password encryption charafantah Programming 4 10-07-2006 06:13 AM
Password Encryption morningkiran Linux - Security 2 10-10-2004 07:17 AM
password encryption Lanmate Linux - Security 2 12-26-2003 04:15 AM
Password encryption???: shakeeb Linux - General 4 11-07-2003 07:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration