• 微擎 人人商城小程序获取不到用户信息


    有可能是 addons/ewei_shopv2/plugin/app/core/wxapp/pkcs7Encoder.php 这个文件的加密代码需要升级了

    全部替换成下面这个

    <?php
    
    require_once EWEI_SHOPV2_PLUGIN . "app/core/wxapp/errorCode.php";
    /**
     * PKCS7Encoder class
     *
     * 提供基于PKCS7算法的加解密接口.
     */
    class PKCS7Encoder
    {
        public static $block_size = 16;
        /**
         * 对需要加密的明文进行填充补位
         * @param $text 需要进行填充补位操作的明文
         * @return 补齐明文字符串
         */
        public function encode($text)
        {
            $block_size = PKCS7Encoder::$block_size;
            $text_length = strlen($text);
            $amount_to_pad = PKCS7Encoder::$block_size - $text_length % PKCS7Encoder::$block_size;
            if ($amount_to_pad == 0) {
                $amount_to_pad = PKCS7Encoder::block_size;
            }
            $pad_chr = chr($amount_to_pad);
            $tmp = "";
            for ($index = 0; $index < $amount_to_pad; $index++) {
                $tmp .= $pad_chr;
            }
            return $text . $tmp;
        }
        /**
         * 对解密后的明文进行补位删除
         * @param decrypted 解密后的明文
         * @return 删除填充补位后的明文
         */
        public function decode($text)
        {
            $pad = ord(substr($text, -1));
            if ($pad < 1 || 32 < $pad) {
                $pad = 0;
            }
            return substr($text, 0, strlen($text) - $pad);
        }
    }
    /**
     * Prpcrypt class
     *
     *
     */
    class Prpcrypt
    {
        public $key = NULL;
        public function Prpcrypt($k)
        {
            $this->key = $k;
        }
        /**
         * 对密文进行解密 php7.0以下
         * @param string $aesCipher 需要解密的密文
         * @param string $aesIV 解密的初始向量
         * @return string 解密得到的明文
         */
        /*  public function decrypt($aesCipher, $aesIV)
          {
              try {
                  $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, ""); exit('4545454');
                  mcrypt_generic_init($module, $this->key, $aesIV);
                  $decrypted = mdecrypt_generic($module, $aesCipher);
                  mcrypt_generic_deinit($module);
                  mcrypt_module_close($module);
              } catch (Exception $e) {
                  return array(ErrorCode::$IllegalBuffer, NULL);
              }
              try {
                  $pkc_encoder = new PKCS7Encoder();
                  $result = $pkc_encoder->decode($decrypted);
              } catch (Exception $e) {
                  return array(ErrorCode::$IllegalBuffer, NULL);
              }
              return array(0, $result);
          }*/
    
    
        public function decrypt( $aesCipher, $aesIV )
        {
            try {
    
    
                $decrypted = openssl_decrypt($aesCipher,'AES-128-CBC',$this->key,OPENSSL_ZERO_PADDING,$aesIV);
                // var_dump($decrypted);
            } catch (Exception $e) {
                return array(ErrorCode::$IllegalBuffer, null);
            }
            try {
                //去除补位字符
                $pkc_encoder = new PKCS7Encoder;
                $result = $pkc_encoder->decode($decrypted);
            } catch (Exception $e) {
                //print $e;
                return array(ErrorCode::$IllegalBuffer, null);
            }
            return array(0, $result);
        }
    }
    
    ?>
    技术最菜,头发最少
  • 相关阅读:
    iis部署网站打不开
    微信小程序全选多选效果
    清除浮动
    IIS_常见问题及解决方法
    文字闪烁效果
    IIS 伪静态 脚本映射 配置方法
    批量删除QQ空间说说
    自定义input文件上传 file的提示文字及样式
    使用google api material icons在网页中插入图标
    jquery日期插件jquery.datePicker参数
  • 原文地址:https://www.cnblogs.com/gushengyan/p/12605599.html
Copyright © 2020-2023  润新知