IT Community - Software Programming, Web Development and Technical Support

How to encrypt app.config file in .net.?

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. ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-17-2007, 10:59 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default How to encrypt app.config file in .net.?

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Web.config nhoj ASP and ASP.NET Programming 8 12-10-2007 11:07 PM
Change the Asp.net (C#) Web.config file a.deeban ASP and ASP.NET Programming 1 08-18-2007 04:42 AM
Ruby on Rails server config vivekanandan Ruby 7 08-04-2007 05:02 AM
What is Machine.config? H2o ASP and ASP.NET Programming 1 07-24-2007 03:18 AM
How to Edit the web.config file elements using c#? Archer C# Programming 0 07-17-2007 10:55 PM


All times are GMT -7. The time now is 08:38 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0