/// <summary> /// 创建sha1签名 /// </summary> /// <returns></returns> public string CreateSHA1Sign() { StringBuilder sb = new StringBuilder(); ArrayList akeys = new ArrayList(Parameters.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)Parameters[k]; if (null != v && "".CompareTo(v) != 0 && "sign".CompareTo(k) != 0 && "key".CompareTo(k) != 0) { if (sb.Length == 0) { sb.Append(k + "=" + v); } else { sb.Append("&" + k + "=" + v); } } } string paySign = SHA1Util.GetSha1(sb.ToString()).ToString().ToLower(); //debug信息 this.SetDebugInfo(sb.ToString() + " => sign:" + paySign); return(paySign); }
/// <summary> /// 判断微信维权签名 /// </summary> /// <returns></returns> public virtual Boolean IsWXsignfeedback() { StringBuilder sb = new StringBuilder(); Hashtable signMap = new Hashtable(); foreach (string k in XmlMap.Keys) { if (SignField.IndexOf(k.ToLower()) != -1) { signMap.Add(k.ToLower(), XmlMap[k]); } } signMap.Add("appkey", this.Appkey); ArrayList akeys = new ArrayList(signMap.Keys); akeys.Sort(); foreach (string k in akeys) { string v = (string)signMap[k]; if (sb.Length == 0) { sb.Append(k + "=" + v); } else { sb.Append("&" + k + "=" + v); } } string sign = SHA1Util.GetSha1(sb.ToString()).ToString().ToLower(); this.SetDebugInfo(sb.ToString() + " => SHA1 sign:" + sign); return(sign.Equals(XmlMap["AppSignature"])); }