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
  • 相关阅读:
    多线程面试题
    Tcpdump MySQL Query
    Gossip和Redis集群原理
    mysql-table_open_cache_file_limits/
    introducing-backup-locks-percona-server-2/
    MySQL 一致性读 深入研究
    how-to-configure-mysql-masterslave-replication-with-mha-automatic-failover/
    mysqlOOM
    mysql 线程池
    Linux performance monitor tool
  • 原文地址:https://www.cnblogs.com/guoyachao/p/9479460.html
Copyright © 2011-2022 走看看