What should I do? after mcrypt_encrypt () is encrypted in Chinese, it is displayed as garbled characters. after the Restoration, the Chinese & nbsp; is displayed on the page. it is not a coding problem & nbsp; why is it garbled after encryption? What should I do? & lt; meta & nbsp; http-equiv = "Content-Type" what should I do? after mcrypt_encrypt () is encrypted in Chinese, it is displayed as garbled characters.
Chinese characters displayed on the page are not encoding problems
Why is it garbled after encryption? What should I do?
Header ("Content-Type: text/html; charset = utf-8 ");
$ Str = "Moonlight in front of bed, suspected to be frost on the ground"; // encrypted content
$ Key = "key: 111"; // key
$ Cipher = MCRYPT_DES; // encryption algorithm type
$ Mode = MCRYPT_MODE_ECB; // encryption algorithm mode
$ Iv = mcrypt_create_iv (mcrypt_get_iv_size ($ cipher, $ mode), MCRYPT_RAND); // Initialization vector
Echo "before encryption". $ str ."
";
// Encryption
$ Str_encrypt = mcrypt_encrypt ($ cipher, $ key, $ str, $ mode, $ iv );
Echo "encrypted". $ str_encrypt ."
";
// Restore
$ Str_decrypt = mcrypt_encrypt ($ cipher, $ key, $ str_encrypt, $ mode, $ iv );
Echo "restore". $ str_decrypt ."
";
?>
------ Solution --------------------
// Restore
$ Str_decrypt = mcrypt_decrypt ($ cipher, $ key, $ str_encrypt, $ mode, $ iv );
Echo "restore". $ str_decrypt ."
";