登录网站后加密信息的最佳方法是什么? [英] What is the best way to encrypt information after login on the website?

查看:104
本文介绍了登录网站后加密信息的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户登录网站后加密密码,电子邮件,用户名和其他信息,并在cookie中加密。我刚接触php



这是我用于密码加密和解密的php。



我新手到php 。如果你有比我更好的方法,请告诉我在哪里改进。



 function encryptionKey($ password){
$ password = strtolower($ password);
return 数组(hash( sha256 ,$ password));
}
函数加密($ enpassword){

return trim(base64_encode(mcrypt_encrypt)(MCRYPT_RIJNDAEL_256,substr($ enpassword [0],0,32),$ enpassword,MCRYPT_MODE_CBC,substr($ enpassword [1],0,32))));
}
函数解密($ depassword){
return mcrypt_decrypt(MCRYPT_RIJNDAEL_256,substr($ depassword [0],0,32) ),base64_decode($ depassword),MCRYPT_MODE_CBC,substr($ depassword [1],0,32)
);
}

公共函数hashPassword($ password){
$ saltpassword = $ password 5138hyh8g0ghg3g5h;
$ encpassword = hash(' sha256' ,$ saltpassword);
return $ encpassword ;
}

解决方案

密码){


密码 = strtolower(


密码);
return 数组(hash( sha256

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;
}

解决方案

password) {


password = strtolower(


password); return array(hash("sha256",


这篇关于登录网站后加密信息的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆