Is there a way to encrypt the configuration file of a Windows forms application?
All I can find on google is stuff that is dependant on “aspnet_regiis.exe” but I want to do this for a desktop application?
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.
What are you trying to accomplish?
Remember that the program itself needs to decrypt the file, and, in your case, the EXE file will be on the end-users machines.
Therefore, anyone who has access to the config file will almost definitely have the EXE as well, and there is no way to prevent them from reading it.
If you’re storing the end-user’s password and want to prevent other people from reading it, you could call
File.Encrypton the path to the file. Note that this won’t work in XP Home.You can also use the
ProtectedDataclass in System.Security.dll to encrypt a byte array such that only the logged on user can decrypt it, then store that byte array in the config file. (This will work in XP home, AFAIK)