点击一次 - 如何连接字符串加密 [英] Click-Once - How to encrypt connection strings

查看:142
本文介绍了点击一次 - 如何连接字符串加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF应用程序存储在App.config连接字符串。什么是点击一次部署这些加密连接字符串的最佳方式?

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?

感谢

推荐答案

如果这是将配置和一台计算机(在多台计算机共享)您的应用程序实例上使用的connectionString,您可以使用.NET托管的DPAPI(数据保护API)的包装 - 的的 ProtectedData类(System.Security.Cryptography)。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆