A small example of php mcrypt encryption and decryption

WBOY
Release: 2016-07-25 08:56:21
Original
935 people have browsed it
  1. /**

  2. * mcrypt encryption and decryption
  3. * by bbs.it-home.org
  4. */
  5. $data = 'data';
  6. $key = "key";

  7. $algorithm = MCRYPT_BLOWFISH;

  8. $mode = MCRYPT_MODE_CBC;
  9. $iv = mcrypt_create_iv(mcrypt_get_iv_size($algorithm,$mode), MCRYPT_DEV_URANDOM);

  10. $encrypted_data = mcrypt_encrypt($algorithm, $key, $data, $mode, $iv);

  11. $decrypted_data = mcrypt_decrypt($algorithm, $key, $encrypted_data, $mode, $iv);

  12. print "解密数据为:$decrypted_data";

  13. ?>

复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template