Interface Mirror

Proper Solutions to Software Development Problems

  Home  |   Contact  |   Syndication    |   Login
  18 Posts | 8 Stories | 16 Comments | 1 Trackbacks

News



Article Categories

Archives

Post Categories

Link

Hi,

I was looking a simple way to be able to encrypt and decrypt my Connection Strings. I searched in the net but all i could find was Encrypting and decrypting Connection Strings using aspnet_regiis utility or by creating custom Encryption and decryption classes.
Finally I could a very good way to do encryption and decryption using .NET class library. You can find the video of the tutorial in asp.net , Videos section (Video is called ASP.NET Tips and Tricks) or read it HERE .

I am placing a sample code in following lines of code as well.

 // Encryption
  Configuration config= WebConfigurationManager . OpenWebConfiguration ( Request . ApplicationPath );
        ConfigurationSection configuration = config.GetSection ("connectionStrings");
        if ( configuration != null )
        {
            if ( ! configuration.SectionInformation.IsProtected )
            {
                configuration . SectionInformation . ProtectSection ( "DataProtectionConfigurationProvider" );
                config . Save ( );
            }
        }
   // Decryption
 Configuration config= WebConfigurationManager . OpenWebConfiguration ( Request . ApplicationPath );
        ConfigurationSection configuration = config . GetSection ( "connectionStrings" );
        if ( configuration != null )
        {
            if ( configuration . SectionInformation . IsProtected )
            {
                configuration . SectionInformation . UnprotectSection ( );
                config . Save ( );
            }
        }
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Sunday, July 20, 2008 2:16 PM