public static string getCheckValue(string merchantId, string returnUrl, string paymentTypeObjId, string amtStr, string merTransId) { string xmlKey = File.ReadAllText(".\\wwwroot\\" + merchantId + ".xml");//img/productimg/1/H1.jpg RSAParameters PrvKeyInfo = RSAUtility.GetPrvKeyFromXmlString(xmlKey); RSACng rsa = new RSACng(); rsa.ImportParameters(PrvKeyInfo); string orgString = merchantId + merTransId + paymentTypeObjId + amtStr + returnUrl; ASCIIEncoding byteConverter = new ASCIIEncoding(); byte[] orgData = byteConverter.GetBytes(orgString); byte[] signedData = rsa.SignData(orgData, HashAlgorithmName.MD5, RSASignaturePadding.Pkcs1); return(Convert.ToBase64String(signedData)); }
public static bool PaymentVerify(HttpRequest curRequest, out string merId, out string amt, out string merTransId, out string transId, out string transTime) { merId = curRequest.Form["merId"].ToString(); amt = curRequest.Form["amt"].ToString(); merTransId = curRequest.Form["merTransId"].ToString(); transId = curRequest.Form["transId"].ToString(); transTime = curRequest.Form["transTime"].ToString(); string checkValue = curRequest.Form["checkValue"].ToString(); string PaymentPublicKey = File.ReadAllText(".\\wwwroot\\PaymentPublicKey.txt"); RSAParameters PubKeyInfo = RSAUtility.GetPubKeyFromXmlString(PaymentPublicKey); string orgString = merId + merTransId + amt + transId + transTime; ASCIIEncoding byteConverter = new ASCIIEncoding(); byte[] orgData = byteConverter.GetBytes(orgString); byte[] signedData = Convert.FromBase64String(checkValue); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); rsa.ImportParameters(PubKeyInfo); return(rsa.VerifyData(orgData, signedData, HashAlgorithmName.MD5, RSASignaturePadding.Pkcs1)); }