Exemple #1
0
        /// <summary>
        /// 创建package签名,按参数名称a-z排序,遇到空值的参数不参加签名。
        /// </summary>
        /// <returns></returns>
        public string CreateMd5Sign()
        {
            var sb    = new StringBuilder();
            var akeys = new ArrayList(Parameters.Keys);

            akeys.Sort();
            foreach (string k in akeys)
            {
                var v = (string)Parameters[k];
                if (null != v && String.Compare("", v, StringComparison.Ordinal) != 0 &&
                    String.Compare("sign", k, StringComparison.Ordinal) != 0 && String.Compare("key", k, StringComparison.Ordinal) != 0)
                {
                    sb.Append(k + "=" + v + "&");
                }
            }
            sb.Append("key=" + GetKey());
            var sign = MD5Util.GetMD5(sb.ToString(), GetCharset()).ToUpper();

            return(sign);
        }
Exemple #2
0
        public static string GetNoncestr()
        {
            var random = new Random();

            return(MD5Util.GetMD5(random.Next(1000).ToString(CultureInfo.InvariantCulture), "GBK"));
        }