收藏
回答

微信步数获取解密数据为空

审核类型 框架类型 问题类型 提审时间 AppID
代码审核 小游戏 Bug 2020-04-03 wxfb82d9e33c0f8167

public function bushu(){


        $appid = 'wxfb82d9e33c0f8167';

        $sessionKey = 'CBC5sc1aBK8iwI3NJlYGgw==';

        $encryptedData="wiFHxHh8tVMLk8wZIjPo2IAE1MInz9J6F1LrY5Pw9wHC+4XJoa/Fh1NIv8S1JO+TrExtrnDEDJyFh9aflO1BKa1pvyUzUJtXV5wcqG2FLyLe+XKdMiJx9/v4fFxwnGpjRTpcyrwFH+2MuTfP4vymws7Ne9WRQqWqi/Gbqc97cN/Qm9bD3Ey1Vh0DGdIXXgR+NrLGfmqukFpE3W0gWiWzNkl5GpUTVbGPXTjlyEVM2CLv3FAziGiUx0QaAQy4DQQwQCXlWsinOvDI1PzZj1Ggh+IdLkcDaokfQcVCsdEr8ZHmOssUob1MgRVAll/+sIN4CjspnqWSHTYPGVZnGTUC+QNqZ5tNT1Sc91fHZM10Bkbl+0ebBvksSQPHH3p3XW0DUZ+sf7pK5tilI2CdP1g00uEMUz1pycJMVqNivHyofWuE6wmOk4LsyvSFvtxLezuUEZ/KI/qjqPn8+MSqREO4ylPTARvsdzKeNPKhDAHK/YswjaPG7jUv0LL6//Or72qI6SMEGdML5lAJZkM0yGlwYSWkEkj5dxWIxmRaN6hJgy77A9vmdk7kcGPhw+AZBkr3SDKlWHjplLt4uMzFPvDrdo8fhnNSGzQFDAckiVpN7t4/nPna5NJlNgzURHbtfroJqVIGKorGRaCEzhEyhLk0peWEWqeyFjlRi4tqDKDzDCGb+VVu3gFyo8Hf8dOQPTs8D3lTTuNoI7DJa9fz6dBZa5t4XGXmvCaRluefulHhEWWI+UqZdr+VY13ayYdLOLe2F6nmOK+Ibw7Z9LnznG38O9GCFsUdZ3xAOt+pD3AZ2FgD2bhMu+pR9j3wFoM2ecxnzgAsmU7+8ihTSYLu/BKDHW773LqGYSq/zcycdMsiJ+nrZISOHoiotl4MHNZO7lBCy8pKhMkD4eaVB60pO8+8GbIHCqOwRwLFWVPTvprA6/259bFquwCegSfU5Jrm1iVudSZ7jrC0kpX8ul2hFBIEjdu5JK4cFWQSxqHQ5XVITtequTxhf9/vN5OwySbVRVMQelxTX1/0FYHszz8OAsct/MdzDJQ8y3lr1KGaBxMeNlKyrkM60Q0KM5HCIvs/7tjs+TDf4hYzruWowgzEjPRjoVfvuD2NNngslse/ODR4N2n7f6pz7ILkifZPLQ6zh3C8fUPBAhvvL0/WPB3QaptmQipUpkTt+ScjZSukGUWouLlbX4M0aDJNDaedtcokasC9mGoRLdEFOSrNVIe1Fdsh8goafpCYYLd+aN7xnisKJTpc+67yymIxblnBK9krAMxyns3w6TUFhFCGkCyiKnrRjU6Gln93HhZfXlsGpRTi2io7nYx9uYqDpQob184js1oh0x8uGg5J7LyjFuRYNRedjyx51rpGoFRS6x7bOHDzSC1qp4zGLukI2R+eQ/GL/ysIUYSHvy26PD4ViKpNtxph3SEF3tsJEUTvFpNLbtp+6e/7qcme+zmMPGgxL25n6m8GDaKW2KiXKLccpO33Ej1Ie1//Moirf3CPe8y8THwlIaifoU9L3b/A4F6FoYKqs3skUSI+V7GBiMHzsczSDn0/7+tUS3Ri1Tx23ZMnlHtFvfWFVIs9N2zbMJGcZC2xeB7Znn4CHCibIHlx1pj0YbDmT6iAVUn9L1jVMT1fJXfIk3Q=";


        $iv = 'N7reVcfDiKSeT4JY7LsdEA==';

        $errCode = $this->jiemi($appid, $sessionKey,$encryptedData, $iv, $data);


        if ($errCode == 0) {

            print($data . "\n");

        } else {

            print($errCode . "\n");

        }

    }

    public function jiemi($appid,$sessionKey,$encryptedData, $iv, &$data){

        if (strlen($sessionKey) != 24) {

            return ErrorCode::$IllegalAesKey;

        }

        $aesKey=base64_decode($sessionKey);


        

        if (strlen($iv) != 24) {

            return ErrorCode::$IllegalIv;

        }

        $aesIV=base64_decode($iv);


        $aesCipher=base64_decode($encryptedData);


        $result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);


        $dataObj=json_decode( $result );

        if( $dataObj  == NULL )

        {

            return ErrorCode::$IllegalBuffer;

        }

        if( $dataObj->watermark->appid != $appid )

        {

            return ErrorCode::$IllegalBuffer;

        }

        $data = $result;

        return ErrorCode::$OK;

    }

回答关注问题邀请回答
收藏
登录 后发表内容
问题标签