public int VerifyURL(string sMsgSignature, string sTimeStamp, string sNonce, string sEchoStr, ref string sReplyEchoStr) { if (this.m_sEncodingAESKey.Length != 43) { return(-40004); } int num = WXBizMsgCrypt.VerifySignature(this.m_sToken, sTimeStamp, sNonce, sEchoStr, sMsgSignature); if (num != 0) { return(num); } sReplyEchoStr = ""; string corpid = ""; try { sReplyEchoStr = RoadFlow.Platform.WeiXin.Cryptography.AES_decrypt(sEchoStr, this.m_sEncodingAESKey, ref corpid); } catch (Exception ex) { sReplyEchoStr = ""; return(-40007); } if (!(corpid != this.m_sCorpID)) { return(0); } sReplyEchoStr = ""; return(-40005); }
private static int VerifySignature(string sToken, string sTimeStamp, string sNonce, string sMsgEncrypt, string sSigture) { string sMsgSignature = ""; int num = WXBizMsgCrypt.GenarateSinature(sToken, sTimeStamp, sNonce, sMsgEncrypt, ref sMsgSignature); if (num != 0) { return(num); } return(sMsgSignature == sSigture ? 0 : -40001); }
public int DecryptMsg(string sMsgSignature, string sTimeStamp, string sNonce, string sPostData, ref string sMsg) { if (this.m_sEncodingAESKey.Length != 43) { return(-40004); } XmlDocument xmlDocument = new XmlDocument(); string innerText; try { xmlDocument.LoadXml(sPostData); innerText = xmlDocument.FirstChild["Encrypt"].InnerText; } catch (Exception ex) { return(-40002); } int num = WXBizMsgCrypt.VerifySignature(this.m_sToken, sTimeStamp, sNonce, innerText, sMsgSignature); if (num != 0) { return(num); } string corpid = ""; try { sMsg = RoadFlow.Platform.WeiXin.Cryptography.AES_decrypt(innerText, this.m_sEncodingAESKey, ref corpid); } catch (FormatException ex) { sMsg = ""; return(-40010); } catch (Exception ex) { sMsg = ""; return(-40007); } return(corpid != this.m_sCorpID ? -40005 : 0); }
public int EncryptMsg(string sReplyMsg, string sTimeStamp, string sNonce, ref string sEncryptMsg) { if (this.m_sEncodingAESKey.Length != 43) { return(-40004); } string sMsgEncrypt; try { sMsgEncrypt = RoadFlow.Platform.WeiXin.Cryptography.AES_encrypt(sReplyMsg, this.m_sEncodingAESKey, this.m_sCorpID); } catch (Exception ex) { return(-40006); } string sMsgSignature = ""; int num = WXBizMsgCrypt.GenarateSinature(this.m_sToken, sTimeStamp, sNonce, sMsgEncrypt, ref sMsgSignature); if (num != 0) { return(num); } sEncryptMsg = ""; string str1 = "<Encrypt><![CDATA["; string str2 = "]]></Encrypt>"; string str3 = "<MsgSignature><![CDATA["; string str4 = "]]></MsgSignature>"; string str5 = "<TimeStamp><![CDATA["; string str6 = "]]></TimeStamp>"; string str7 = "<Nonce><![CDATA["; string str8 = "]]></Nonce>"; sEncryptMsg = sEncryptMsg + "<xml>" + str1 + sMsgEncrypt + str2; sEncryptMsg = sEncryptMsg + str3 + sMsgSignature + str4; sEncryptMsg = sEncryptMsg + str5 + sTimeStamp + str6; sEncryptMsg = sEncryptMsg + str7 + sNonce + str8; sEncryptMsg += "</xml>"; return(0); }