示例#1
0
        public string GetSignature()
        {
            //String plain = string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}", ticket, nonceStr, timeStamp, url);
            string randomStr = DingTalkSignatureUtil.GetRandomStr(10);
            string timeStamp = TopUtils.GetCurrentTimeMillis().ToString();

            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add(Constants.JSAPI_TICKET, _cacheHelper.Get(Constants.JSAPI_TICKET).ToString());
            dic.Add(Constants.NONCESTR, randomStr);
            dic.Add(Constants.TIMESTAMP, timeStamp);
            dic.Add(Constants.URL, AppSettings.Get(Constants.URL));

            _cacheHelper.Add(Constants.NONCESTR, randomStr);
            _cacheHelper.Add(Constants.TIMESTAMP, timeStamp);

            try
            {
                byte[] bytes             = Encoding.UTF8.GetBytes(ConvertDictionaryToString(dic));
                byte[] digest            = SHA1.Create().ComputeHash(bytes);
                string digestBytesString = BitConverter.ToString(digest).Replace("-", "");
                _cacheHelper.Add(Constants.SIGNATURE, digestBytesString.ToLower());
                return(digestBytesString.ToLower());
            }
            catch (Exception e)
            {
                throw;
            }
        }
示例#2
0
 public BaseDingTalkService()
 {
     corpid      = AppSettings.Get("corpid");
     corpsecret  = AppSettings.Get("corpsecret");
     agentid     = AppSettings.Get("agentid");
     appkey      = AppSettings.Get("appkey");
     appsecret   = AppSettings.Get("appsecret");
     url         = AppSettings.Get("url");
     registerurl = AppSettings.Get("registerurl");
     timestamp   = TopUtils.GetCurrentTimeMillis().ToString();
     noncestr    = DingTalkSignatureUtil.GetRandomStr(10);
 }