public string ReplyMessageMiddle(string replyMsg)
        {
            string replyMsgEncrypted = CryptographyHelper.AESEncrypt(replyMsg, _baseSettings.EncodingAESKey, _baseSettings.AppId);
            string timestamp         = UtilityHelper.GetTimeStamp().ToString();
            string nonce             = UtilityHelper.GenerateNonce();
            string signature         = SignatureGenerater.GenerateSignature(_baseSettings.Token, timestamp, nonce, replyMsgEncrypted);

            StringBuilder sb = new StringBuilder();

            sb.Append($"<xml>");
            sb.Append($"<Encrypt><![CDATA[{replyMsgEncrypted}]]></Encrypt>");
            sb.Append($"<MsgSignature><![CDATA[{signature}]]></MsgSignature>");
            sb.Append($"<TimeStamp><![CDATA[{timestamp}]]></TimeStamp>");
            sb.Append($"<Nonce><![CDATA[{nonce}]]></Nonce>");
            sb.Append($"</xml>");

            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 签名有效性验证
        /// </summary>
        /// <param name="signature">签名</param>
        /// <param name="strings">生成签名的字符串</param>
        /// <returns></returns>
        public bool VerifySignature(string signature, params string[] strings)
        {
            string sign = SignatureGenerater.GenerateSignature(strings);

            return(sign == signature);
        }