Would like to know the best way to encrypt and decrypt an XML file that serve as a database ?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are XML encryption APIs included in the .NET Framework that use symmetric and assymetrics keys.
You can also use the standard .NET AES encryption classes for this from any .NET language but you’d have to manually operate on the element/attribute values in the XML (or encrypt it all as one big string). If you are using it as a database encryption can cause some issues if you can’t decrypt all of it in one shot. For example if you need to search multiple elements there is going to be a cost to decrypting each one to check the values.
Encryption is not perfect on its own you have to protect the keys used to encrypt the data. Look into the SecureString class and the DPAPI API for protection of the keys, although there may be better APIs for doing this. If you have bugs in your crypto code you might as well not have any encryption, so try to write as little as possible and make sure you have the code reviewed by an expert.