订阅消息加解密指南
订阅消息加解密指南
概述
AESKey=Base64_Decode(EncodingAESKey + "=")
使用已有库
初始化加解密类
WBMsgCrypt wbcpt(sToken,sEncodingAESKey,sReceiveId);
验证URL函数
1.
2.
int VerifyURL(const string &sMsgSignature, const string &sTimeStamp, const string &sNonce, const string &sEchoStr, string &sReplyEchoStr);
参数 | 必须 | 说明 |
---|---|---|
sMsgSignature | 是 | 从接收消息的URL中获取的msg_signature参数 |
sTimeStamp | 是 | 从接收消息的URL中获取的timestamp参数 |
sNonce | 是 | 从接收消息的URL中获取的nonce参数 |
sEchoStr | 是 | 从接收消息的URL中获取的echostr参数。注意,此参数必须是urldecode后的值 |
sReplyEchoStr | 是 | 解密后的明文消息内容,用于回包。注意,必须原样返回,不要做加引号或其它处理 |
解密函数
1.
2.
int DecryptMsg(const string &sMsgSignature, const string &sTimeStamp, const string &sNonce, const string &sPostData, string &sMsg);
参数 | 必须 | 说明 |
---|---|---|
sMsgSignature | 是 | 从接收消息的URL中获取的msg_signature参数 |
sTimeStamp | 是 | 从接收消息的URL中获取的timestamp参数 |
sNonce | 是 | 从接收消息的URL中获取的nonce参数 |
sPostData | 是 | 从接收消息的URL中获取的整个post数据 |
sMsg |