The configuration API has been expanded greatly to allow for new features such as writing and encryption.  In the past, doing these tasks were not convenient at all but now they are relatively easy.  The web.config has many new sections as you will come to find out.  A new <connectionStrings/> section has been added specifically for connection strings.  
Encrypting your connectionStrings now is easy.  Simply write a page to do the initial encryption.
// get an instance of the configuration object
Configuration configuration = Configuration.GetWebConfiguration(Request.ApplicationPath);
// get the connection strings section
ConnectionStringsSection connectionStringsSection = configuration.ConnectionStrings;
// encrypt using DPAPI
// update the web.config
To access your encrypted connections strings, you don't have to do a thing.  Instead of using the AppSettings property, just use the Configuration.ConnectionStrings

Read the complete post at