zoukankan      html  css  js  c++  java
  • PHP手册在7.1迁移页面给出了替代方案,就是用OpenSSL取代MCrypt.

    /**
     * [AesSecurity aes加密,支持PHP7.1]
     */
    class AesSecurity
    {
        /**
         * [encrypt aes加密]
         * @param    [type]                   $input [要加密的数据]
         * @param    [type]                   $key   [加密key]
         * @return   [type]                          [加密后的数据]
         */
        public static function encrypt($input, $key)
        {
            $data = openssl_encrypt($input, 'AES-128-ECB', $key, OPENSSL_RAW_DATA);
            $data = base64_encode($data);
            return $data;
        }
        /**
         * [decrypt aes解密]
         * @param    [type]                   $sStr [要解密的数据]
         * @param    [type]                   $sKey [加密key]
         * @return   [type]                         [解密后的数据]
         */
        public static function decrypt($sStr, $sKey)
        {
            $decrypted = openssl_decrypt(base64_decode($sStr), 'AES-128-ECB', $sKey, OPENSSL_RAW_DATA);
            return $decrypted;
        }
    }

    文章转自http://www.tech1024.com/original/1266.html
  • 相关阅读:
    datagridview中读取数据判断+考勤每月上班天数判断
    dateTimePicker日期比较+时间段内查询+员工查询薪资步骤+datagridview
    c#word 存取
    位图去空白
    过桥问题
    Dominos 2(DFS)(容器)
    poj 3421(三分)
    poj 3186(DP)
    安装Ubuntu
    poj 3273(二分)
  • 原文地址:https://www.cnblogs.com/guoyachao/p/9479460.html
Copyright © 2011-2022 走看看