/// <summary> /// 数据加密密 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns>RequestBaseModel</returns> public PayRequestBaseModel apiResult <T>(T model, string Path, string Pwd, string MerchantId, string UserKey) where T : RequestBase, new() { PayRequestBaseModel baseModel = new PayRequestBaseModel(); string certAdd = @"" + Path; model.UserKey = UserKey; baseModel.MerchantId = MerchantId; string certPwd = Pwd; model.Ip = "127.0.0.1"; model.Mac = "F4-6D-04-35-B5-A1"; model.TimesTamp = DateTime.Now.ToString("yyyy-MM-dd HH:ss:dd"); string jsonData = JsonConvert.SerializeObject(model); model.Sign = Encrpty.MD5Encrypt(jsonData + model.UserKey); string aesKey = Cryptor.GenerateAESKey(); string d = Encrpty.AESEecrypt(JsonConvert.SerializeObject(model), aesKey); aesKey = Encrpty.RSAEcrypt(aesKey, certAdd); baseModel.Data = d; baseModel.EncryptKey = aesKey; return(baseModel); }
public void Init(CheckTicketRequestView param) { param.CompanyId = Convert.ToInt32(JsonConfig.JsonRead("CheckTicketForACompanyId", "CheckTicketForA")); param.RequestTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); _param = JsonConvert.SerializeObject(param); _key = JsonConfig.JsonRead("CheckTicketForAKey", "CheckTicketForA"); _sign = Encrpty.MD5Encrypt(_param + _key).ToUpper(); }
public CheckTicketProcessor(string uuid) { _Hashcode = CheckTicketHashcode; _uuid = uuid; _outstyle = "4"; _Key = CheckTicketKey; _sign = Encrpty.MD5Encrypt(_Hashcode + _outstyle + _uuid + _Key + DateTime.Now.ToString("yyyyMMdd")).ToLower(); }
/// <summary> /// sign加密 /// </summary> /// <param name="contents"></param> /// <returns></returns> public string Sign(Dictionary <string, object> contents) { var sortedContents = string.Join("&", from key in contents.Keys where key != "sign" && !key.Equals("sign_type") orderby key select key.ToLower() + "=" + (contents[key] ?? string.Empty)); return(Encrpty.MD5Encrypt(sortedContents.Trim('&') + "cgt").ToLower()); }
/// <summary> /// 执行操作form提交数据 /// </summary> /// <returns></returns> public string ExecuteForm(RequestTradePay pay) { var UrlNotify = JsonConfig.JsonRead("bg_ret_url", "Dingshuapay"); Encoding utf8 = Encoding.UTF8; string checkstr = JsonConfig.JsonRead("version", "Dingshuapay") + JsonConfig.JsonRead("cust_id", "Dingshuapay") + pay.OrderId + pay.AcctIdcard + pay.Subject + JsonConfig.JsonRead("gate_id", "Dingshuapay") + pay.TransAmt + pay.CardId + pay.MobileNo + pay.AcctName + pay.AcctIdcard + pay.BankNum + pay.AcctCardno + pay.TradeRate + pay.DrawFee + pay.RetUrl + this.UrlEncode(UrlNotify, utf8, true) + pay.MerPriv + pay.Extension + JsonConfig.JsonRead("userkey", "Dingshuapay"); string check_value = Encrpty.MD5Encrypt(checkstr); StringBuilder sbHtml = new StringBuilder(); sbHtml.Append("<form action='" + JsonConfig.JsonRead("DingshuapayUrl", "Dingshuapay") + "' method='post' name='merRecvRequest' >"); sbHtml.Append("<input type='hidden' name='version' value='" + JsonConfig.JsonRead("version", "Dingshuapay") + "'/>"); sbHtml.Append("<input type='hidden' name='cust_id' value='" + JsonConfig.JsonRead("cust_id", "Dingshuapay") + "'/>"); sbHtml.Append("<input type='hidden' name='ord_id' value='" + pay.OrderId + "'/>"); sbHtml.Append("<input type='hidden' name='sub_mer_id' value='" + pay.AcctIdcard + "'/>"); sbHtml.Append("<input type='hidden' name='subject' value='" + pay.Subject + "'/>"); sbHtml.Append("<input type='hidden' name='gate_id' value='" + JsonConfig.JsonRead("gate_id", "Dingshuapay") + "'/>"); sbHtml.Append("<input type='hidden' name='trans_amt' value='" + pay.TransAmt + "'/>"); sbHtml.Append("<input type='hidden' name='card_id' value='" + pay.CardId + "'/>"); sbHtml.Append("<input type='hidden' name='mobile_no' value='" + pay.MobileNo + "'/>"); sbHtml.Append("<input type='hidden' name='acct_name' value='" + pay.AcctName + "'/>"); sbHtml.Append("<input type='hidden' name='acct_idcard' value='" + pay.AcctIdcard + "'/>"); sbHtml.Append("<input type='hidden' name='bank_num' value='" + pay.BankNum + "'/>"); sbHtml.Append("<input type='hidden' name='acct_cardno' value='" + pay.AcctCardno + "'/>"); sbHtml.Append("<input type='hidden' name='trade_rate' value='" + pay.TradeRate + "'/>"); sbHtml.Append("<input type='hidden' name='draw_fee' value='" + pay.DrawFee + "'/>"); sbHtml.Append("<input type='hidden' name='ret_url' value='" + pay.RetUrl + "'/>"); sbHtml.Append("<input type='hidden' name='bg_ret_url' value='" + this.UrlEncode(UrlNotify, utf8, true) + "'/>"); sbHtml.Append("<input type='hidden' name='mer_priv' value='" + pay.MerPriv + "'/>"); sbHtml.Append("<input type='hidden' name='extension' value='" + pay.Extension + "'/>"); sbHtml.Append("<input type='hidden' name='check_value' value='" + check_value + "'/>"); sbHtml.Append("</form>"); sbHtml.Append("<script>document.forms['merRecvRequest'].submit();</script> "); //CGT.DDD.Logger.LoggerFactory.Instance.Logger_Info(string.Format(@"提交参数:{0},提交加密参数:{1}", json, sbHtml.ToString()), "ReapalRecharge"); return(sbHtml.ToString()); }
/// <summary> /// 获取MySign /// </summary> private string GetMySign(string userkey) { string MySign = Encrpty.MD5Encrypt(string.Format(@"AgentId={0}&TimesTamp={1}&Ip={2}&Mac={3}{4}" , this.Parameter.AgentId , this.Parameter.TimesTamp , this.Parameter.Ip , this.Parameter.Mac , userkey)); return(MySign); }
public PreRegistrationProcessor(List <PreRegistrationRequestView> lstticket) { _Hashcode = CheckTicketHashcode; _NotifyURL = CheckTicketNotifyURL; _uuid = ""; _lstticket = lstticket; _Key = CheckTicketKey; string str = _Hashcode + _NotifyURL + _uuid + _Key + DateTime.Now.ToString("yyyyMMdd"); _sign = Encrpty.MD5Encrypt(str).ToLower(); }
/// <summary> /// 获取MySign /// </summary> private string GetMySign(string userkey) { //MySign =(MerchantId = 12345 & TimesTamp = 2017 - 01 - 25 10:21:49 & Ip=167.0.12.31 & MAC = aaaa)+UserKey的值 string MySign = Encrpty.MD5Encrypt(string.Format(@"MerchantId={0}&TimesTamp={1}&Ip={2}&Mac={3}{4}" , model.MerchantId , this.Parameter.TimesTamp , this.Parameter.Ip , this.Parameter.Mac , userkey)); return(MySign); }
private string PrepareRequest() { var encoding = Encoding.GetEncoding(ParameterEncodingName); var parametersJson = PrepareRequestCore(); var md5Str = Encrpty.MD5Encrypt(parametersJson + JsonConfig.JsonRead("md5Key", "Installment")); var aesStr = Encrpty.AESEecrypt(parametersJson, JsonConfig.JsonRead("aesKey", "Installment")); Collection.DDD.Logger.LoggerFactory.Instance.Logger_Info(string.Format("提交参数:{0}", parametersJson), "InstallmentService"); var request = new RequestView() { data = aesStr, midPlatform = JsonConfig.JsonRead("md5Key", "midPlatform"), sign = md5Str, version = JsonConfig.JsonRead("md5Key", "version") }; return(JsonConvert.SerializeObject(request)); }