0% found this document useful (0 votes)
181 views2 pages

XML Encryption with TripleDES

This code encrypts a specific element called "person" in an XML file using TripleDES encryption. It loads an XML file containing personal information, encrypts the "person" element using a TripleDES key, and saves the encrypted XML to a new file.

Uploaded by

api-3841500
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
181 views2 pages

XML Encryption with TripleDES

This code encrypts a specific element called "person" in an XML file using TripleDES encryption. It loads an XML file containing personal information, encrypts the "person" element using a TripleDES key, and saves the encrypted XML to a new file.

Uploaded by

api-3841500
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Encrypt data in XML file

The following code helps you to encrypt the specified element in an XML file using TripleDES algorithm. In
this code, an element named "person" is encrypted.

The following XML data is stored in a file [Link].

<?xml version="1.0" encoding="UTF­8"?>
<persons>
<person>
     <name>Bala</name>
     <company>Trendz</company>
</person>
</persons>

// The following code encrypts the person element in the input XML file and produces encrypted
file.

// Load this XML file
[Link] myDoc = new [Link]();
[Link](@"c:\[Link]");

// Get a specified element to be encrypted
[Link] element = 
[Link]("person")[0] as [Link];

// Create a new TripleDES key. 
[Link] tDESkey = 
new [Link]();

// Form a Encrypted XML with the Key
[Link] encr = new 
[Link]();
[Link]("Deskey", tDESkey);

// Encrypt the element data
[Link] ed = 
[Link](element,"Deskey");

// Replace the existing data with the encrypted data
[Link](element, 
ed, false);

// saves the xml file with encrypted data
[Link](@"c:\[Link]");

You might also like