Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click-Once - How to encrypt connection strings [duplicate]

I have a WPF application with connections strings stored in the App.config. What is the best way of encrypting these connection strings in a click-once deployment?

Thanks

like image 409
Gus Cavalcanti Avatar asked May 20 '09 21:05

Gus Cavalcanti


1 Answers

If this is a connectionString that will be configured and used on a single computer (not shared across multiple computers) by an instance of your application, you can use the .NET managed wrapper of the DPAPI (Data Protection API) - the ProtectedData class (System.Security.Cryptography).

A neat trick you could also use (should you decide to use this class) is to create extension methods for Encoding and Decoding a string, so the operations become as simple as:

string encodedString = myConnectionString.EncodeString();

string decodedString = encodedString.DecodeString();

Hope this helps!

like image 153
Mark Carpenter Avatar answered Sep 20 '22 17:09

Mark Carpenter