How do I creating and read encrypted XML files with VB.Net?

Posted on 2008-10-28
Last Modified: 2012-05-05
Hey all,

I am having a bit of trouble figuring out how to write out and read back some encrytped XML files using VB.Net 2005 and could use some help.  

What I am trying to do is two fold:
-One:  Save the contents of a loaded XMLDocument object as an encrypted XML file (the type of encryption does not matter; however, speed of decryption will be important down the road.
-Two:  Read the contents of the encrypted file back into an XMLDocument object which I can then run some Xpath statements against.

The key would be known by both the program doing the encryption as well as the program doing the decryption.

Seems straight-forward.  I have found a lot of great XML/encryption/decryption examples but nothing that quite fits.  Your help is appreciated.
Question by:dgnatek
  • 3
LVL 12

Accepted Solution

techExtreme earned 500 total points
Comment Utility
Have a look at this tutorial, it explains well about encrypting xml docs then decrypting them back and reading the content back.
Hope it helped!


Author Comment

Comment Utility
Thats a fine start.  However the example references an EncryptedXML object, supposedly part of System.Security.Cryptography.Xml.  However, I do not not have an XML (or XML.EncryptedXml) under System.Security.Cryptography.  I am on v2.0 of the framework.  Any suggestions?

Imports System

Imports System.Security.Cryptography

Imports System.Security.Cryptography.Xml             <=== Does not exist.

Imports System.Xml

Open in new window


Author Comment

Comment Utility
As a followup to the above comment, it is necessary to add a reference to Sytem.Security.dll in your project properties before references to System.Security.Cryptography.Xml are valid.  Just adding an Imports statement was/is not enough.

Author Closing Comment

Comment Utility
I was really hoping for a VB.Net based solution (example).  However, I was able to decode the C# stuff.  Thanks.

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: btan
Provide an easy one stop to quickly get the relevant information on common asked question on Ransomware in Expert Exchange.
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now