Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            #region 获取套件配置参数
            string m_Token = ConfigurationManager.AppSettings["Token"];
            if (string.IsNullOrEmpty(m_Token))
                Helper.WriteLog("token没有配置");
            string m_SuiteKey = ConfigurationManager.AppSettings["SuiteKey"];
            if (string.IsNullOrEmpty(m_Token))
                Helper.WriteLog("token没有配置");
            string m_EncodingAESKey = ConfigurationManager.AppSettings["EncodingAESKey"];
            if (string.IsNullOrEmpty(m_Token))
                Helper.WriteLog("token没有配置");
            #endregion
            //构造DingTalkCrypt
            DingTalkCrypt dingTalk = new DingTalkCrypt(m_Token, m_EncodingAESKey, m_SuiteKey);

            string sVerifyMsgSig = txtMsgSig.Text.Trim();
            string sVerifyTimeStamp = txtTimeStamp.Text.Trim();
            string sVerifyNonce = txtNonce.Text.Trim();
            string encryptStr = txtEncryptStr.Text.Trim();

            string sEchoStr = "";

            int ret = dingTalk.VerifyURL(sVerifyMsgSig, sVerifyTimeStamp, sVerifyNonce, encryptStr, ref sEchoStr);
            txtEchoStr.Text = sEchoStr;

            //string sMsg = "";
            //ret = dingTalk.DecryptMsg(sVerifyMsgSig, sVerifyTimeStamp, sVerifyNonce, encryptStr, ref sMsg);

            //string sEncryptMsg = "";
            //dingTalk.EncryptMsg("success", sVerifyTimeStamp, sVerifyNonce, ref sEncryptMsg);

            // sVerifyTimeStamp = "1441713878094";
            // sVerifyNonce = "ZjJmiMAu";
            //dingTalk.EncryptMsg("success", sVerifyTimeStamp, sVerifyNonce, ref sEncryptMsg);
        }
Пример #2
0
 public int VerifyURL(string mToken,string mEncodingAesKey, string msgSignature, string timeStamp,string nonce,string encryptStr,ref string suiteKey)
 {
     var ret = 0;
     List<SuiteKeyInfo> suikKeyList = new Select().From(SuiteKeyInfo.Schema).ExecuteTypedList<SuiteKeyInfo>();
     foreach (SuiteKeyInfo suiteKeyInfo in suikKeyList)
     {
         DingTalkCrypt dingTalk = new DingTalkCrypt(mToken, mEncodingAesKey, suiteKeyInfo.SuiteKey);
         string sEchoStr = "";
         ret = dingTalk.VerifyURL(msgSignature, timeStamp, nonce, encryptStr, ref sEchoStr);
         if (ret == 0)
         {
             IsvReceive isvReceive = new IsvReceive
             {
                 Signature = msgSignature,
                 Timestamp = timeStamp,
                 Nonce = nonce,
                 Encrypt = encryptStr,
                 EchoString = sEchoStr,
                 CreateTime = DateTime.Now
             };
             isvReceive.Save();
             suiteKey = suiteKeyInfo.SuiteKey;
             return ret;
         }
     }
     return ret;
 }