public string SignMD5WithRSA(string strSource, string strPrivateKeyPath)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(strPrivateKeyPath);
            XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("RSAKeyValue");

            elementsByTagName.Item(0).SelectSingleNode("Modulus").InnerText  = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("Modulus").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("Exponent").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("Exponent").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("P").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("P").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("Q").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("Q").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("DP").InnerText       = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("DP").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("DQ").InnerText       = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("DQ").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("InverseQ").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("InverseQ").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("D").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("D").InnerText.Trim()));
            string      innerXml             = xmlDocument.InnerXml;
            RSACryption rSACryption          = new RSACryption();
            string      strHashbyteSignature = "";

            rSACryption.GetHash(strSource, ref strHashbyteSignature);
            string result = "";

            rSACryption.SignatureFormatter(innerXml, strHashbyteSignature, ref result);
            return(result);
        }
Пример #2
0
        public string SignMD5WithRSA(string strSource, string strPrivateKeyPath)
        {
            XmlDocument document = new XmlDocument();

            document.Load(strPrivateKeyPath);
            XmlNodeList elementsByTagName = document.GetElementsByTagName("RSAKeyValue");

            elementsByTagName[0].SelectSingleNode("Modulus").InnerText  = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("Modulus").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("Exponent").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("Exponent").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("P").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("P").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("Q").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("Q").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("DP").InnerText       = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("DP").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("DQ").InnerText       = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("DQ").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("InverseQ").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("InverseQ").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("D").InnerText        = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("D").InnerText.Trim()));
            string      innerXml    = document.InnerXml;
            RSACryption cryption    = new RSACryption();
            string      strHashData = "";

            cryption.GetHash(strSource, ref strHashData);
            string str3 = "";

            cryption.SignatureFormatter(innerXml, strHashData, ref str3);
            return(str3);
        }
        public bool UnsignMD5WithRSA(string strSignData, string strSource, string strPublicKeyPath)
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.Load(strPublicKeyPath);
            XmlNodeList elementsByTagName = xmlDocument.GetElementsByTagName("RSAKeyValue");

            elementsByTagName.Item(0).SelectSingleNode("Modulus").InnerText  = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("Modulus").InnerText.Trim()));
            elementsByTagName.Item(0).SelectSingleNode("Exponent").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName.Item(0).SelectSingleNode("Exponent").InnerText.Trim()));
            string      innerXml    = xmlDocument.InnerXml;
            RSACryption rSACryption = new RSACryption();
            string      p_strHashbyteDeformatter = "";

            rSACryption.GetHash(strSource, ref p_strHashbyteDeformatter);
            return(rSACryption.SignatureDeformatter(innerXml, p_strHashbyteDeformatter, strSignData));
        }
Пример #4
0
        public bool UnsignMD5WithRSA(string strSignData, string strSource, string strPublicKeyPath)
        {
            XmlDocument document = new XmlDocument();

            document.Load(strPublicKeyPath);
            XmlNodeList elementsByTagName = document.GetElementsByTagName("RSAKeyValue");

            elementsByTagName[0].SelectSingleNode("Modulus").InnerText  = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("Modulus").InnerText.Trim()));
            elementsByTagName[0].SelectSingleNode("Exponent").InnerText = Convert.ToBase64String(this.GetBytes(elementsByTagName[0].SelectSingleNode("Exponent").InnerText.Trim()));
            string      innerXml    = document.InnerXml;
            RSACryption cryption    = new RSACryption();
            string      strHashData = "";

            cryption.GetHash(strSource, ref strHashData);
            if (!cryption.SignatureDeformatter(innerXml, strHashData, strSignData))
            {
                return(false);
            }
            return(true);
        }