/// <summary> /// MD5签名 /// </summary> /// <returns></returns> public string GetCftPackage(Dictionary <string, string> bizObj) { if (string.IsNullOrEmpty(Key)) { throw new Exception("Key为空!"); } string unSignParaString = CommonUtil.FormatBizQueryParaMapForUnifiedPay(bizObj); return(MD5SignUtil.Sign(unSignParaString, Key)); }
/// <summary> /// 生成 订单详情 (package) /// </summary> /// <returns></returns> public string GetCftPackage() { if ("" == PartnerKey) { throw new SDKRuntimeException("密钥不能为空!"); } string unSignParaString = CommonUtil.FormatBizQueryParaMap(parameters, false); string paraString = CommonUtil.FormatBizQueryParaMap(parameters, true); return(paraString + "&sign=" + MD5SignUtil.Sign(unSignParaString, PartnerKey)); }
/// <summary> /// 验证 package的签名(MD5) (已测试通过) /// </summary> /// <param name="dic"></param> /// <param name="sign"></param> /// <returns></returns> public bool ValidateMD5Signature(Dictionary <string, string> dic, string sign) { //验证 参数不能为空 foreach (var item in dic) { if (string.IsNullOrEmpty(item.Value)) { return(false); } } if ("" == PartnerKey) { throw new SDKRuntimeException("密钥不能为空!"); } string unSignParaString = CommonUtil.FormatBizQueryParaMap(dic, false); return(MD5SignUtil.VerifySignature(unSignParaString, sign, PartnerKey)); }