The registry represents one possible location for an application to store database connection strings. Although individual registry keys can be secured with Windows access control lists (ACLs), for added security you should store encrypted connection strings.
This How To describes how to store an encrypted database connection string in the registry and retrieve it from an ASP.NET Web application. It uses the generic encryption and decryption managed class library created in “How to: Create an Encryption Library,” which can be found in Reference section of this book.
If you have not already created the encryption class library assembly, do so before continuing with the current How To.
For more information about other locations and ways of securely storing database connection strings, see “Storing Database Connection Strings Securely” in Chapter 12, “Data Access Security.”