/// <summary> /// 加密消息 /// </summary> /// <param name="wxcpt"></param> /// <param name="token"></param> /// <param name="encryptMsg"></param> /// <returns></returns> public int EncryptMessage(WXBizMsgCrypt wxcpt, string token, out string encryptMsg) { encryptMsg = string.Empty; var serializeMessage = this.AsXmlString(); string timeSpan = DateTime.Now.Subtract(dateInit).TotalSeconds.ToString(); string replyMsg = serializeMessage; string msgSignature = string.Empty; string nonce = DateTime.Now.Ticks.ToString(); int encryptResult = wxcpt.EncryptMsg(replyMsg, timeSpan, nonce, ref encryptMsg); if (encryptResult != 0) { return(encryptResult); } int genSinatureResult = WXBizMsgCrypt.GenerateSinature(token, timeSpan, nonce, encryptMsg, ref msgSignature); return(genSinatureResult); }