Exemple #1
0
        private void BtnASimetrico_Click(object sender, RoutedEventArgs e)
        {
            consola.Text = "";

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.PreserveWhitespace = true;
            xmlDoc.LoadXml(txtClaro.Text);
            CspParameters cspParams = new CspParameters();

            cspParams.KeyContainerName = "XML_ENC_RSA_KEY";
            RSACryptoServiceProvider rsaKey = new RSACryptoServiceProvider(cspParams);

            ESign.Encrypt(xmlDoc, txtEtiqueta.Text, "EncryptedElement1", rsaKey, "rsaKey");
            txtSalida.Text = xmlDoc.InnerXml;

            XmlDocument xmlDoc2 = new XmlDocument();

            xmlDoc2.PreserveWhitespace = true;
            xmlDoc2.LoadXml(txtSalida.Text);

            ESign.Decrypt(xmlDoc2, rsaKey, "rsaKey");
            WriteLine(xmlDoc2.InnerXml);
            rsaKey.Clear();
        }
Exemple #2
0
        private void BtnCertificado_Click(object sender, RoutedEventArgs e)
        {
            consola.Text = "";

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.PreserveWhitespace = true;
            xmlDoc.LoadXml(txtClaro.Text);

            var store = new X509Store(StoreLocation.CurrentUser);

            store.Open(OpenFlags.ReadOnly);
            var cert = store.Certificates.Find(X509FindType.FindBySubjectName, txtCertificado.Text, false)[0];

            store.Close();
            ESign.Encrypt(xmlDoc, "creditcard", cert);
            txtSalida.Text = xmlDoc.InnerXml;

            XmlDocument xmlDoc2 = new XmlDocument();

            xmlDoc2.PreserveWhitespace = true;
            xmlDoc2.LoadXml(txtSalida.Text);
            ESign.Decrypt(xmlDoc2);
            WriteLine(xmlDoc2.InnerXml);
        }
Exemple #3
0
        private void DesEncSim(SymmetricAlgorithm key)
        {
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.PreserveWhitespace = true;
            xmlDoc.LoadXml(txtSalida.Text);
            ESign.Decrypt(xmlDoc, key);
            WriteLine(xmlDoc.InnerXml);
        }