Ejemplo n.º 1
0
        public string GetSignature(string timestamp, string noncestr, string url)
        {
            WxChatHelper wxChartInfo = new WxChatHelper();
            string       string1     = "jsapi_ticket=" + new WxChatHelper().GetAccessToken_formDb() + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;

            //使用sha1加密这个字符串
            return(wxChartInfo.SHA1_Hash(string1));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取用于JsApi分享功能的签名signature
        /// </summary>
        /// <returns></returns>
        public string GetSignature(string url)
        {
            WxChatHelper wxChartInfo = new WxChatHelper();

            //string url = page.Request.Url.AbsoluteUri.ToString().Trim().Split('#')[0]; //Replace("http://", " ")
            if (string.IsNullOrEmpty(JsApiTicket))
            {
                JsApiTicket = wxChartInfo.GetJsApiTicket();
            }
            else
            {
                int timestampOld = Convert.ToInt32(JsApiTicket.Split(',')[1]);
                int timestampNow = wxChartInfo.ConvertDateTimeInt(DateTime.Now);
                if (timestampNow - timestampOld >= 3000)
                {
                    JsApiTicket = wxChartInfo.GetJsApiTicket();
                }
            }
            //string jsApiTicket = wxChartInfo.GetJsApiTicket();
            string rawstring = "jsapi_ticket=" + JsApiTicket.Split(',')[0] + "&noncestr=" + nonceStr + "&timestamp=" + timestamp + "&url=" + url + "";

            return(wxChartInfo.SHA1_Hash(rawstring));
        }