记登录注册时候前端js明⽂密码加密传输php解密前端使⽤key iv 使⽤aes加密后字符串传给后台(可拼接时间戳加密)
function js_encrypt(text){
var key = Latin1.parse('1E390CMD585LLS4S'); //为了避免补位,直接⽤16位的秘钥
var iv = Latin1.parse('1104432290129056'); //16位初始向量(请记住这两个都要保证是16位)
var encrypted = pt(text, key, {
iv: iv,
de.CBC,
js代码加密软件padding:CryptoJS.pad.ZeroPadding
});
return encrypted;
}
$password = input('password');
$password_dec=iconv('utf-8','gbk',js_decrypt_openssl($password));
$timesm=substr($password_dec,-10);
$password = str_replace($timesm,'',$password_dec);
if(time() > $timesm + 10){
$errcode = 10006;
return json(['errcode'=>$errcode,'errmsg'=>errcode::getErrMsg($errcode)]);
}
function js_decrypt_openssl($encrypt){
$key = "****"; //与JS端的KEY⼀致
$iv = "****"; //这个也是要与JS中的IV⼀致
$decrypted = openssl_decrypt($encrypt, 'AES-128-CBC', $key, 2 , $iv);
$decrypted = trim(trim($decrypted, "\0000"),'');//这个⼀定要有,要不然在你不⽤浏览器查看源代码的情况下是很难发现,还有⼀些乱码存在的return$decrypted;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。