Reputation: 684
Just read this article http://tutorialslink.com/Articles/Encrypt-and-Decrypt-Connection-Strings-in-Webconfig/52
they said if we use this command then connection string will be encrypted aspnet_regiis.exe -pef "connectionStrings" "<Path of the Folder containing the Web.Config file>"
and
say this command will decrypt the connection string aspnet_regiis.exe -pdf "connectionStrings" "<Path of the Folder containing the Web.Config file>"
but the problem is if we follow this approach it may not work when we host our web site in different pc.
so please tell me what approach we should follow to encrypt / decrypt connection string or any section in web.config which will work in any pc.
thanks in advance.
Upvotes: 1
Views: 2910
Reputation: 1325
I don't know how sensitive your data is, but I suppose you could try the following:
Decrypt the string in your code, using something like this
private string getConnectionString()
{
string encrypted = System.Configuration.
ConfigurationManager.AppSettings["connectionString"];
//Rijndael or any other form of decryption here...
//.....
//.....
return decryptedString;
}
Use the decrypted connectionString to connect to your database! :)
Upvotes: 1