/// <summary> /// 获取返回时的签名验证结果 /// </summary> /// <param name="inputPara">通知返回参数数组</param> /// <param name="sign">对比的签名结果</param> /// <param name="signType">签名方式</param> /// <param name="key">交易安全校验码</param> /// <param name="code">字符编码格式</param> /// <returns>签名验证结果</returns> private static bool GetSignVeryfy(SortedDictionary <string, string> inputPara, string sign, string signType, string key, Encoding code) { Dictionary <string, string> sPara = new Dictionary <string, string>(); //过滤空值、sign与sign_type参数 sPara = AlipayCore.FilterPara(inputPara); //获取待签名字符串 string preSignStr = AlipayCore.CreateLinkString(sPara); //获得签名验证结果 bool isSgin = false; if (sign != null && sign != "") { switch (signType) { case "MD5": isSgin = AlipayMD5.Verify(preSignStr, sign, key, code); break; default: break; } } return(isSgin); }
/// <summary> /// 获取返回时的签名验证结果 /// </summary> /// <param name="inputPara">通知返回参数数组</param> /// <param name="sign">对比的签名结果</param> /// <returns>签名验证结果</returns> private static bool GetAppSignVeryfy(SortedDictionary <string, string> inputPara, string sign, string signType, string publicKey, string appInputCharset) { Dictionary <string, string> sPara = new Dictionary <string, string>(); //过滤空值、sign与sign_type参数 sPara = AlipayCore.FilterPara(inputPara); //获取待签名字符串 string preSignStr = AlipayCore.CreateLinkString(sPara); //获得签名验证结果 bool isSgin = false; if (sign != null && sign != "") { switch (signType) { case "RSA": isSgin = AlipayRSAFromPkcs8.verify(preSignStr, sign, publicKey, appInputCharset); break; default: break; } } return(isSgin); }