Jump to content

Encrypting passwords in PHP


kayla

Recommended Posts

I am creating a client zone for a company as part of a uni project.

 

I was thinking of creating a php page for employees to log in and edit or add passwords for clients.

 

My only problem comes when encrypting the passwords.

I've heard of salting and hashing but I'm not sure of what would be best to use.

The data is being accessed by the clients is on an Access db (not ideal for multiple access, i know)

 

Also, when the client logs in with their password will it automatically be recognised?

Or will i need code which de-encrypts it?

 

Sorry if I don't make much sense, but any help would be greatly appreciated!  :shy:

Link to comment
Share on other sites

Hashing cannot be reversed, technically. Adding salt will remove the attacker's ability to use Rainbow tables (precalculated hash attacks basically) on the hash. It's faster and recommended to use hashing, much faster than decrypting.

<?php  
$password = 'mypassword';  
$salt=')_*]$';  
$saltedHash = md5($pass . $salt);  
echo $saltedHash;  
?>

When the user enters his password, it rehashes it, sends it to the DB and checks if the password hashes are the same. Straightforward from there.

if ( (md5($_POST['...']) . $salt) == xxxxxxxxxxxxx ) {//hash from database 
  //so on.. allow them to change their pass.
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.