AESKey=Base64_Decode(EncodingAESKey + "=")
WBMsgCrypt wbcpt(sToken,sEncodingAESKey,sReceiveId);
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 | 是 | 解密后的明文消息内容,用于回包。注意,必须原样返回,不要做加引号或其它处理 |
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 | 是 | 用于返回解密后的msg,以json组织 |
int EncryptMsg(const string &sReplyMsg, const string &sTimeStamp, const string &sNonce, string &sEncryptMsg);
参数 | 必须 | 说明 |
---|---|---|
sReplyMsg | 是 | 返回的消息体原文 |
sTimeStamp | 是 | 时间戳,调用方生成 |
sNonce | 是 | 随机数,调用方生成 |
sEncryptMsg | 是 | 用于返回的密文,以json组织 |
dev_msg_signature=sha1(sort(token、timestamp、nonce、msg_encrypt))。
rand_msg = random(16B) + msg_len(4B) + msg + corp_id
msg_encrypt = Base64_Encode(AES_Encrypt(rand_msg))
aes_msg=Base64_Decode(msg_encrypt)
rand_msg=AES_Decrypt(aes_msg)