WPF: App.config Encryption

Topics: Cryptography Application Block, Data Access Application Block, Security Application Block
Apr 28, 2009 at 8:47 PM
I am developing a WPF application to be deployed via ClickOnce, and need to find a solid example for encrypting the ConnectionString within my app.config file.

Nearly all the examples I have found are for ASP.Net using aspnet_regiis.exe and have been told that renaming app.config to web.config is a hack that can be used. But we all know hacks aren't smart for enterprise applications.

I am unfamiliar with the Enterprise Library though I've been reading different things about the Cryptography Block. Does anyone have an example on how to accomplish this task?

Furthermore, does anyone have an example without using the Enterprise Library? I would prefer not to, but if it is the only solution available for WPF .Net applications, than it will be decided.

Thanks, III
Apr 29, 2009 at 9:24 AM

Have you came across to this link: http://entlib.codeplex.com/Wiki/View.aspx?title=How%20do%20I%20encrypt%20or%20decrypt%20the%20configuration%20section%3f&referringTitle=Home, have a look, this might help. 

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Mar 30, 2012 at 12:08 PM

I have a similar situation.  I have a Windows Forms application using Enterprise Library 5.0 that will be deployed using ClickOnce.  The connection strings section is encrypted; all examples i've found are for ASP.NET on a web server.

The application potentially could go out to 100's of users, each with their own computer.  The question is how to handle this?

Thanks in advance,

Richard Thomas

Mar 30, 2012 at 12:54 PM

The ASP.NET approach (using aspnet_regiis) does work for other application types.  Whether that approach is satisfactory or not depends on your requirements.

This thread goes into more detail.

Randy Levy
Enterprise Library support engineer