Пример #1
0
        public void Decrypt(XmlDocument xmlDocument)
        {
            XmlElement    encOrderElem = xmlDocument.GetElementsByTagName("EncryptedData")[0] as XmlElement;
            EncryptedData encData      = new EncryptedData();

            encData.LoadXml(encOrderElem);

            TripleDESCryptoServiceProvider encryptionKey = new TripleDESCryptoServiceProvider();

            encryptionKey.Key = SettingsEncryptionKey.GetKey();
            EncryptedXml encryptedXml = new EncryptedXml();

            byte[] decryptedOrder = encryptedXml.DecryptData(encData, encryptionKey);

            encryptedXml.ReplaceData(encOrderElem, decryptedOrder);
        }
Пример #2
0
        public void Encrypt(XmlDocument xmlDocument)
        {
            TripleDESCryptoServiceProvider encryptionKey = new TripleDESCryptoServiceProvider();

            encryptionKey.Key = SettingsEncryptionKey.GetKey();
            XmlElement   orderElem = xmlDocument.DocumentElement as XmlElement;
            EncryptedXml encXml    = new EncryptedXml(xmlDocument);

            byte[]        encryptedOrder = encXml.EncryptData(orderElem, encryptionKey, false);
            EncryptedData encryptedData  = new EncryptedData();

            encryptedData.Type             = EncryptedXml.XmlEncElementUrl;
            encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl);

            encryptedData.CipherData             = new CipherData();
            encryptedData.CipherData.CipherValue = encryptedOrder;
            EncryptedXml.ReplaceElement(orderElem, encryptedData, false);
        }