private JDPayDictionary BuildEncryptDic <T>(IJDPayRequest <T> request, IDictionary <string, string> parameters) where T : JDPayResponse { var signDic = new JDPayDictionary(parameters) { { VERSION, request.GetApiVersion() }, { MERCHANT, Options.Merchant }, }; var signContent = JDPaySecurity.GetSignContent(signDic); var sign = JDPaySecurity.RSASign(signContent, PrivateKey); var encyptDic = new JDPayDictionary { { VERSION, request.GetApiVersion() }, { MERCHANT, Options.Merchant }, { SIGN, sign } }; foreach (var iter in parameters) { if (!string.IsNullOrEmpty(iter.Value)) { encyptDic.Add(iter.Key, JDPaySecurity.EncryptECB(iter.Value, DesKey)); } } return(encyptDic); }
private JDPayDictionary BuildEncryptDic <T>(IJDPayRequest <T> request, IDictionary <string, string> dictionary, JDPayOptions options) where T : JDPayResponse { var signDic = new JDPayDictionary(dictionary) { { JDPayContants.VERSION, request.GetApiVersion() }, { JDPayContants.MERCHANT, options.Merchant } }; var signContent = JDPaySecurity.GetSignContent(signDic); var sign = JDPaySecurity.RSASign(signContent, options.PrivateKey); var encyptDic = new JDPayDictionary { { JDPayContants.VERSION, request.GetApiVersion() }, { JDPayContants.MERCHANT, options.Merchant }, { JDPayContants.SIGN, sign } }; foreach (var iter in dictionary) { if (!string.IsNullOrEmpty(iter.Value)) { encyptDic.Add(iter.Key, JDPaySecurity.EncryptECB(iter.Value, options.DesKeyBase64)); } } return(encyptDic); }
private void CheckNotifySign(JDPayDictionary parameters) { if (parameters.Count == 0) { throw new Exception("sign check fail: parameters is Empty!"); } if (!parameters.TryGetValue(JDPayContants.SIGN, out var sign)) { throw new Exception("sign check fail: sign is Empty!"); } var signContent = JDPaySecurity.GetSignContent(parameters); if (!JDPaySecurity.RSACheckContent(signContent, sign, Options.PublicKey)) { throw new Exception("sign check fail: check Sign and Data Fail"); } }
private void CheckNotifySign(JDPayDictionary dictionary, JDPayOptions options) { if (dictionary.Count == 0) { throw new JDPayException("sign check fail: dictionary is Empty!"); } if (!dictionary.TryGetValue(JDPayContants.SIGN, out var sign)) { throw new JDPayException("sign check fail: sign is Empty!"); } var signContent = JDPaySecurity.GetSignContent(dictionary); if (!JDPaySecurity.RSACheckContent(signContent, sign, options.PublicKey)) { throw new JDPayException("sign check fail: check Sign and Data Fail"); } }