Пример #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 = TenPayAPI.GetMD5(signkey, "utf-8");


            return(sign);
        }
Пример #2
0
        /// <summary>
        /// 随机串
        /// </summary>
        public static string GetNoncestr()
        {
            Random random = new Random();

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