public static JDPayDictionary EncryptData(string signCert, string password, string envelopCert, JDPayDictionary dic, string singKey, string encryptType, bool isEncrypt) { var encryptData = new JDPayDictionary(); var data = GetNPP10SignContentOrEncryptContent(dic); dic.TryGetValue(JDPayContants.CUSTOMER_NO, out var customerNo); dic.TryGetValue(JDPayContants.SIGN_TYPE, out var signType); if (!isEncrypt || string.IsNullOrEmpty(encryptType)) { dic.Add(JDPayContants.SIGN_DATA, GetNPP10Sign(data, signType, singKey)); encryptData = dic; } else { encryptData.Add(JDPayContants.SIGN_TYPE, signType); encryptData.Add(JDPayContants.SIGN_DATA, GetNPP10Sign(data, signType, singKey)); encryptData.Add(JDPayContants.CUSTOMER_NO, customerNo); encryptData.Add(JDPayContants.ENCRYPT_TYPE, encryptType); if ("RSA" == encryptType) { encryptData.Add(JDPayContants.ENCRYPT_DATA, SignEnvelop(signCert, password, envelopCert, data)); } else { throw new Exception("不支持的加密方式"); } } return(encryptData); }
public static bool VerifySign(JDPayDictionary dic, string key) { dic.TryGetValue(JDPayContants.SIGN_TYPE, out var algorithm); dic.TryGetValue(JDPayContants.SIGN_DATA, out var sign); dic.Remove(JDPayContants.SIGN_TYPE); dic.Remove(JDPayContants.SIGN_DATA); return(Verify(sign, dic, algorithm, key)); }