php中实现mcrypt加密与解决的例子。
代码:
<?
/**
* mcrypt加密与解密
* by www.jb200.com
*/
$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";
?>