Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

encrypt SQL connectionstring c#

I created an c# application (not asp webpage) which connects to a sql 2005 server. In my sourcecode the password and userid for this sql-server is coded plain text in ConnectionString.

SqlConnection con = new SqlConnection();
con.ConnectionString = 
         "Data Source=server1;"+
         "Initial Catalog=mydatabase;"+
         "Integrated Security=no;"+
         "User ID=admin;Password=mypassword;";
con.Open();

Is there a easy way to encrypt password or whole connectionstring, that other peoples who disassemble my tool are not able to see the password?

thanks

like image 962
Tobi Avatar asked Jan 29 '10 07:01

Tobi


People also ask

Can you encrypt a SQL database?

You can use encryption in SQL Server for connections, data, and stored procedures.

How do I encrypt a SQL connection string?

To encrypt a connection from SQL Server Management Studio: On the Object Explorer toolbar, select Connect, and then select Database Engine. In the Connect to Server dialog box, complete the connection information, and then select Options. On the Connection Properties tab, select Encrypt connection.


1 Answers

You should store your connection string in a config file and encrypt that section. See http://www.4guysfromrolla.com/articles/021506-1.aspx or http://msdn.microsoft.com/en-us/library/89211k9b%28VS.80%29.aspx.

like image 140
Jonas Lincoln Avatar answered Oct 08 '22 14:10

Jonas Lincoln