/// <summary> /// 获取返回时的签名验证结果 /// </summary> /// <param name="inputPara">通知返回参数数组</param> /// <param name="sign">对比的签名结果</param> /// <returns>签名验证结果</returns> private bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign) { Dictionary <string, string> sPara = new Dictionary <string, string>(); //过滤空值、sign与sign_type参数 sPara = Core.FilterPara(inputPara); //获取待签名字符串 string preSignStr = Core.CreateLinkString(sPara); preSignStr = preSignStr.Replace("¬", "¬"); //获得签名验证结果 bool isSgin = false; if (sign != null && sign != "") { switch (_sign_type) { case "RSA": //isSgin = Aop.Api.Util.AlipaySignature.RSACheckV1(inputPara,_public_key,_input_charset); isSgin = RSAFromPkcs8.Verify(preSignStr, sign, _public_key, _input_charset); break; case "MD5": isSgin = AlipayMD5.Verify("", sign, _public_key, _input_charset); break; default: break; } } return(isSgin); }
///// <summary> ///// 获取待签名字符串(调试用) ///// </summary> ///// <param name="inputPara">通知返回参数数组</param> ///// <returns>待签名字符串</returns> //private string GetPreSignStr(SortedDictionary<string, string> inputPara) //{ // Dictionary<string, string> sPara = new Dictionary<string, string>(); // //过滤空值、sign与sign_type参数 // sPara = Core.FilterPara(inputPara); // //获取待签名字符串 // string preSignStr = Core.CreateLinkString(sPara); // return preSignStr; //} /// <summary> /// 获取返回时的签名验证结果 /// </summary> /// <param name="inputPara">通知返回参数数组</param> /// <param name="sign">对比的签名结果</param> /// <returns>签名验证结果</returns> public bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign) { Dictionary <string, string> sPara = new Dictionary <string, string>(); //过滤空值、sign与sign_type参数 sPara = Core.FilterPara(inputPara); //获取待签名字符串 string preSignStr = Core.CreateLinkString(sPara); //获得签名验证结果 bool isSgin = false; if (!string.IsNullOrWhiteSpace(sign)) { switch (_signType) { case SignType.RSA: isSgin = RSAFromPkcs8.Verify(preSignStr, sign, _alipayPublicKey, _inputCharset); break; case SignType.MD5: isSgin = AlipayMD5.Verify(preSignStr, sign, _md5Key, _inputCharset); break; default: break; } } return(isSgin); }