Beispiel #1
0
        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);
        }
Beispiel #2
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);
        }