Example #1
0
        /// <summary>
        /// 获取微信签名
        /// </summary>
        /// <param name="sParams"></param>
        /// <returns></returns>
        public string getsign(SortedDictionary <string, string> sParams, string key)
        {
            int           i    = 0;
            string        sign = string.Empty;
            StringBuilder sb   = new StringBuilder();

            foreach (KeyValuePair <string, string> temp in sParams)
            {
                if (temp.Value == "" || temp.Value == null || temp.Key.ToLower() == "sign")
                {
                    continue;
                }
                i++;
                sb.Append(temp.Key.Trim() + "=" + temp.Value.Trim() + "&");
            }
            sb.Append("key=" + key.Trim() + "");
            string signkey = sb.ToString();

            sign = MD5Util.GetMD5(signkey, "utf-8");


            return(sign);
        }
Example #2
0
        /// <summary>
        /// 随机串
        /// </summary>
        public static string getNoncestr()
        {
            Random random = new Random();

            return(MD5Util.GetMD5(random.Next(1000).ToString(), "GBK").ToLower().Replace("s", "S"));
        }