1

What is the best way to automate the encryption of my c#.net application configuration file without interfering with the normal operations of the application?

2 Answers 2

4
  • Here is Microsoft's recommendation.
  • Don't encrypt the whole file, obviously. Just encrypt sensitive data like DB connection strings.
  • You should consider encrypting only the /configuration/appSettings/add[@value] parts.
  • Use your favorite System.Security.Cryptography class.
  • Don't forget that this is a text file so convert binary to hex (e.g. \n => 0A)
Sign up to request clarification or add additional context in comments.

1 Comment

Actually, encoding binary as Base64 would be better. For XML documents don't forget to escape any values that might contain "<", ">", "&", etc. too.
0

If you create seperate functions to encrypt and decrypt a file, as explained here, rather than trying to incorproate it into the existing routines, then you can simply call the decryption routine before loading the file (i.e. at the top of the "Load" function) and call the encryption routine after saving it (i.e. just before returning from the "Save" function).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.