/// <summary> /// 加密消息体 /// </summary> /// <param name="sReplyMsg"></param> /// <param name="config"></param> /// <returns></returns> internal static ResultMo <string> EncryptMsg(string sReplyMsg, WxMsgServerConfig config) { string raw = ""; try { raw = Cryptography.AesEncrypt(sReplyMsg, config.EncodingAesKey, config.AppId); } catch (Exception) { return(new ResultMo <string>(ResultTypes.InnerError, "加密响应消息体出错!")); } var date = DateTime.Now; var sTimeStamp = date.ToUtcSeconds().ToString(); var sNonce = date.ToString("yyyyMMddHHssff"); string msgSigature = GenerateSignature(config.Token, sTimeStamp, sNonce, raw); if (string.IsNullOrEmpty(msgSigature)) { return(new ResultMo <string>(ResultTypes.InnerError, "生成签名信息出错!")); } StringBuilder sEncryptMsg = new StringBuilder(); string EncryptLabelHead = "<Encrypt><![CDATA["; string EncryptLabelTail = "]]></Encrypt>"; string MsgSigLabelHead = "<MsgSignature><![CDATA["; string MsgSigLabelTail = "]]></MsgSignature>"; string TimeStampLabelHead = "<TimeStamp><![CDATA["; string TimeStampLabelTail = "]]></TimeStamp>"; string NonceLabelHead = "<Nonce><![CDATA["; string NonceLabelTail = "]]></Nonce>"; sEncryptMsg.Append("<xml>").Append(EncryptLabelHead).Append(raw).Append(EncryptLabelTail); sEncryptMsg.Append(MsgSigLabelHead).Append(msgSigature).Append(MsgSigLabelTail); sEncryptMsg.Append(TimeStampLabelHead).Append(sTimeStamp).Append(TimeStampLabelTail); sEncryptMsg.Append(NonceLabelHead).Append(sNonce).Append(NonceLabelTail); sEncryptMsg.Append("</xml>"); return(new ResultMo <string>(sEncryptMsg.ToString())); }
public WxBasicMsgService(WxMsgServerConfig mConfig) : base(mConfig) { TextHandler += WxBasicMsgService_TextHandler; }
public WxBasicMsgService(WxMsgServerConfig mConfig) : base(mConfig) { }
public WxMsgService(WxMsgServerConfig config) : base(config) { TextHandler += WxMsgService_TextHandler; }
/// <summary> /// 构造函数 /// </summary> /// <param name="config"></param> public WxMsgHandler(WxMsgServerConfig config) : base(config) { }
public WxMsgService(WxMsgServerConfig config) : base(config) { }
/// <summary> /// 构造函数 /// </summary> /// <param name="mConfig"></param> protected WxMsgBasicHandler(WxMsgServerConfig mConfig) { m_Config = mConfig; }