• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 895
  • Last Modified:

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?
0
Mister_Spock
Asked:
Mister_Spock
  • 3
  • 3
1 Solution
 
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
 
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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 
Mister_SpockAuthor Commented:
Can I get some code that demonstrates this?
0
 
Bob LearnedCommented:
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
 
Mister_SpockAuthor Commented:
Thank you
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now