Пример #1
0
        /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="strSignData">已签名的数据</param>
        /// <param name="strSource">原数据</param>
        /// <param name="strPublicKeyPath">公钥存放路径</param>
        /// <returns>true/false</returns>
        public bool UnsignMD5WithRSA(string strSignData, string strSource, string strPublicKeyPath)
        {
            XmlDocument doc = new XmlDocument();
            // 装入指定的XML文档
            doc.Load(strPublicKeyPath);
            XmlNodeList node = doc.GetElementsByTagName("RSAKeyValue");
            //参数值进行base64编码
            XmlNode selectSingleNode = node[0].SelectSingleNode("Modulus");
            if (selectSingleNode != null)
                selectSingleNode.InnerText = Convert.ToBase64String(GetBytes(selectSingleNode.InnerText.Trim()));
            XmlNode singleNode = node[0].SelectSingleNode("Exponent");
            if (singleNode != null)
                singleNode.InnerText = Convert.ToBase64String(GetBytes(singleNode.InnerText.Trim()));
            string strKeyPublic = doc.InnerXml;

            bool bReturn = false;
            RSACryption RC = new RSACryption();
            string m_strHashbyteDeformatter = "";
            RC.GetHash(strSource, ref m_strHashbyteDeformatter);

            if (RC.SignatureDeformatter(strKeyPublic, m_strHashbyteDeformatter, strSignData) == false)
            {
                bReturn = false;
            }
            else
            {
                bReturn = true;
            }
            return bReturn;

        }