diff --git a/core/aes/demo.php b/core/aes/demo.php index ec0aa1d..8dd060a 100644 --- a/core/aes/demo.php +++ b/core/aes/demo.php @@ -2,6 +2,7 @@ namespace LaneWeChat\Core\Aes; include_once "wxBizMsgCrypt.php"; +// 第三方发送消息给公众平台 $encodingAesKey = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG"; $token = "pamtest"; $timeStamp = "1409304348"; @@ -9,13 +10,14 @@ $nonce = "xxxxxx"; $appId = "wxb11529c136998cb6"; $text = "1407743423"; + $pc = new WXBizMsgCrypt($token, $encodingAesKey, $appId); $encryptMsg = ''; $errCode = $pc->encryptMsg($text, $timeStamp, $nonce, $encryptMsg); if ($errCode == 0) { - print("加密后: " . $encryptMsg . "\n"); + print("加密后: " . $encryptMsg . "\n"); } else { - print($errCode . "\n"); + print($errCode . "\n"); } $xml_tree = new DOMDocument(); @@ -28,10 +30,11 @@ $msg_sign = $array_s->item(0)->nodeValue; $format = ""; $from_xml = sprintf($format, $encrypt); +// 第三方收到公众号平台发送的消息 $msg = ''; $errCode = $pc->decryptMsg($msg_sign, $timeStamp, $nonce, $from_xml, $msg); if ($errCode == 0) { - print("解密后: " . $msg . "\n"); + print("解密后: " . $msg . "\n"); } else { - print($errCode . "\n"); + print($errCode . "\n"); } \ No newline at end of file