예제 #1
0
        public static string getCheckValue(string rootPath, string merchantId, string returnUrl, string paymentTypeObjId, string amtStr, string merTransId)
        {
            string        xmlKey     = File.ReadAllText(rootPath + "\\" + merchantId + ".xml");
            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));
        }
예제 #2
0
        public static bool PaymentVerify(HttpRequest curRequest, string rootPath, 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(rootPath + "\\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));
        }