public function isWechat() { if ($this->isRequired(['msg_signature', 'timestamp', 'nonce'], $_GET)) { extract($_GET); if (empty($_GET['echostr'])) { } else { // 第一次绑定 $echostr = urldecode($echostr); $ary = [$this->Token, $timestamp, $nonce, $echostr]; sort($ary, SORT_STRING); if ($msg_signature == sha1(implode($ary))) { die(CryptStatic::decrypt($echostr, $this->CorpID, $this->EncodingAESKey)); } } } }
/** * 对正常消息进行加密 * @param string $xml * @return SimpleXMLElement */ protected function crypt_generate($xml) { return CryptStatic::encrypt($xml, $this->appid, $this->encodingAesKey); }