闲者博客 - 另类
https://bk1314.com/tag/%E5%8F%A6%E7%B1%BB/
-
PHP加密解密的另类
https://bk1314.com/38.html
2022-02-25T18:51:00+08:00
function encryptDecrypt($key, $string, $decrypt){
if($decrypt){
$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "12");
return $decrypted;
}else{
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));
return $encrypted;
}
}
//加密:
echo encryptDecrypt('password', 'Helloweba欢迎您',0);
//解密:
echo encryptDecrypt('password', 'z0JAx4qMwcF+db5TNbp/xwdUM84snRsXvvpXuaCa4Bk=',1);