点击一次 - 如何加密连接字符串 [英] Click-Once - How to encrypt connection strings
问题描述
谢谢
如果这是一个将配置的connectionString并且通过应用程序的实例在单个计算机(不共享多台计算机)上使用,您可以使用DPAPI(Data Protection API)的.NET托管包装器 - ProtectedData类(System.Security.Cryptography)。
你还可以使用一个整洁的技巧(你应该决定使用这个类)是为字符串编码和解码创建扩展方法,所以操作变得简单:
string encodedString = myConnectionString.EncodeString();
string decodedString = encodedString.DecodeString();
希望这有帮助!
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
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!
这篇关于点击一次 - 如何加密连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!