phpmcrypt加密与解密的小例子
时间:2021-07-01 10:21:17
帮助过:11人阅读
- /**
- * mcrypt加密与解密
- * by bbs.it-home.org
- */
- $data = 'data';
- $key = "key";
$algorithm = MCRYPT_BLOWFISH; - $mode = MCRYPT_MODE_CBC;
- $iv = mcrypt_create_iv(mcrypt_get_iv_size($algorithm,$mode), MCRYPT_DEV_URANDOM);
$encrypted_data = mcrypt_encrypt($algorithm, $key, $data, $mode, $iv); $decrypted_data = mcrypt_decrypt($algorithm, $key, $encrypted_data, $mode, $iv); print "解密数据为:$decrypted_data"; - ?>
|