C# XML Stream of encrypted XML file

C# XML Stream of encrypted XML file
I have used the Rijndael algorithm (System.Security.Crytogrhapy.RijndaelManaged) to encrypt and decrypt a XML file. To give some background, my company changes the Administrator password once every three months or when someone from the IT department or Administrators group leaves the company for whatever reason. This means that the Administrator password may get changed often. The change is deployed through the network and may not touch all PCs, especially laptops. The PCs that are missed may have the previous or second previous Administrator password.

Certain programs can only be run if the person logged into the PC is the Administrator, so I use C# to run as the Administrator. The XML file mentioned above has the current and last two previous Administrator passwords in child nodes. My idea was to decrypt the XML file, read the nodes, determine what Administrator password is on the system and encrypt the XML file once again.

My client has asked that instead of making the XML file human readable, even for a second, that I stream the file into memory, decrypt it, read the child nodes from memory, determine the correct Administrator password then delete the stream. I am not dead-set on keeping this an XML file, but I would like to.
Can someone help me with this?
LVL 3
Mister_SpockAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Hmmm...let's see what Google can find for us:

CryptoStream Class
http://msdn.microsoft.com/en-us/library/system.security.cryptography.cryptostream.aspx
0
 
Bob LearnedCommented:
What kind of "help" are you looking for?  Do you want advice?  Do you want to change the process?  
0
 
Mister_SpockAuthor Commented:
Looking for ways read a XML file into memory, decrypt it and read it.
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Bob LearnedCommented:
You can use the System.Xml.XmlDocument class, which has a Load method overload that takes a stream as an argument.  You can couple streams together (FileStream, CryptoStream, etc.).  The FileStream can read from the file, and the CryptoStream can decrypt the FileStream.  Then, the Load method would take the CryptoStream as the argument.  You would need to find the correct arguments for the CryptoStream constructor (stream, ICryptoTransform, CryptoStreamMode).
0
 
Mister_SpockAuthor Commented:
Can I get some code that demonstrates this?
0
 
Mister_SpockAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.