This is a discussion on How to encrypt app.config file in .net.? within the C# Programming forums, part of the Software Development category; How to encrypt app.config file in .net.? Open Visual Studio 2005, and create a new C# Windows Application project. ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| How to encrypt app.config file in .net.? Open Visual Studio 2005, and create a new C# Windows Application project. Name it DemoWinApp. Open the Settings file, and add a setting named SecretMessage Open Form1’s designer, and add a Label control on it, naming it lblSecretMessage Add the following code in Form1’s Load method. lblSecretMessage.Text = DemoWinApp.Properties.Settings.Default.SecretMessa ge; Open the App.Config file, and add the following code as the child node of the Configuration section. <configProtectedData> <providers> <add useMachineProtection="true" name="DPAPIProtection" type="System.Configuration.DpapiProtectedConfigura tionProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </configProtectedData> The above code is necessary to configure a Protected Configuration provider, which will be used for encrypting and decrypting the configuration section which contains sensitive information. Whenever you want to specify your own provider with custom settings, you can declare a new provider instance using the add element of the providers element under ConfigProtectedData, which in turn is a child element of the Configuration section. The DpapiProtectedConfigurationProvider uses the Windows built-in cryptographic services, and can be configured for either machine-specific or user-account-specific protection. Machine-specific protection is useful for anonymous services, but provides less security. User-account-specific protection can be used with services that run with a specific user identity. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Config File or Registry | shaalini | Server Management | 4 | 06-14-2009 08:41 PM |
| Web.config | nhoj | ASP and ASP.NET Programming | 8 | 12-10-2007 10:07 PM |
| Change the Asp.net (C#) Web.config file | a.deeban | ASP and ASP.NET Programming | 1 | 08-18-2007 03:42 AM |
| What is Machine.config? | H2o | ASP and ASP.NET Programming | 1 | 07-24-2007 02:18 AM |
| How to Edit the web.config file elements using c#? | Archer | C# Programming | 0 | 07-17-2007 09:55 PM |
Our Partners |