I want to encrypt password, email, username and other information after the user logins on the site, encrypt them in the cookies. I new to php
This my php for password encryption and decryption.
I m a newbie to php. If you have better way than mine please tell me where to improve.
function encryptionKey($password) {
$password = strtolower($password);
return array(hash("sha256", $password));
}
function encrypt($enpassword) {
return trim( base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, substr($enpassword[0],0,32),$enpassword, MCRYPT_MODE_CBC, substr($enpassword[1],0,32) )));
}
function decrypt($depassword) {
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256, substr($depassword[0],0,32), base64_decode($depassword),MCRYPT_MODE_CBC, substr($depassword[1],0,32)
);
}
public function hashPassword($password) {
$saltpassword = $password . "5138hyh8g0ghg3g5h";
$encpassword = hash('sha256', $saltpassword);
return $encpassword;
}