Sometimes we don't want to, a web address for people to see, the simple way is to encrypt it into a string of characters, the function is as follows:
function Encrypt ($key, $plain _text) {
$plain _text = Trim ($plain _text);
$IV = substr (MD5 ($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$c _t = MCRYPT_CFB (mcrypt_cast_256, $key, $plain _text, Mcrypt_encrypt, $IV);
Return Trim (Chop (Base64_encode ($c _t));
}
$key can be set with a string, $plain _text to the string you want to encrypt. The corresponding decryption function:
function Decrypt ($key, $c _t) {
$c _t = Trim (Chop (Base64_decode ($c _t));
$IV = substr (MD5 ($key), 0,mcrypt_get_iv_size (MCRYPT_CAST_256,MCRYPT_MODE_CFB));
$p _t = MCRYPT_CFB (mcrypt_cast_256, $key, $c _t, Mcrypt_decrypt, $IV);
Return Trim (Chop ($p _t));
}
$plain _text for the string you want to decrypt;
Note: If you pass an encrypted string as a parameter using a URL, use the UrlEncode () function to encrypt it, otherwise the decrypt ($key, $c _t) function decrypts the obtained parameter without getting the original string.
http://www.bkjia.com/PHPjc/364698.html www.bkjia.com true http://www.bkjia.com/PHPjc/364698.html techarticle sometimes we don't want to, a web address to see, the simple way is to encrypt it into a string of characters, functions as follows: Function Encrypt ($key, $plain _text) {$plain _text = t ...