回答

收藏

aes 256加密及解密

后台知识 后台知识 643 人阅读 | 0 人回复 | 2024-08-31

本帖最后由 zhangchi 于 2024-8-31 17:47 编辑
  1. if(!function_exists('aes_encrypt')){   
  2.     /**
  3.     * aes_encrypt  aes加密
  4.     *
  5.     * @param  mixed $to_encode 加密明文
  6.     * @return void
  7.     */
  8.     function aes_encode($to_encode) {
  9.         $encrypt_method = "aes-256-cfb";
  10.         $encrypt_key = config('login_private');
  11.         $encoded_key = openssl_encrypt($to_encode, $encrypt_method, $encrypt_key, 0, 'abcdefghijklmnop', $tag, "", 11);
  12.         return $encoded_key;
  13.     }
  14. }

  15. if(!function_exists('aes_decode')){   
  16.     /**
  17.     * aes_decrypt  aes解密
  18.     *
  19.     * @param  mixed $encoded_key   密文
  20.     * @return void
  21.     */
  22.     function aes_decrypt($encoded_key) {
  23.         $encrypt_method = "aes-256-cfb";
  24.         $encrypt_key = config('login_private');
  25.         $decoded_key = openssl_decrypt($encoded_key, $encrypt_method, $encrypt_key, 0, 'abcdefghijklmnop');
  26.         return $decoded_key;
  27.     }
  28. }
复制代码


分享到:
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

38 积分
10 主题
+ 关注