c# - 如何在 C# .Net 4.6 WPF 应用程序中隐藏 ConnectionString

标签 c# wpf encryption cryptography connection-string

我有一个与 SQL Server 一起使用的简单 WPF 应用程序。我必须使用什么加密算法来隐藏 wpf 应用程序用户的连接字符串?请不要提供中间件层应用程序。

最佳答案

有一个article来自 MSDN 的用于保护您的连接信息的信息。

深入了解如何使用 protected 配置来加密配置文件here .

要点:

Use Windows Authentication

To help limit access to your data source, you must secure connection information such as user ID, password, and data source name. In order to avoid exposing user information, we recommend using Windows authentication (sometimes referred to as integrated security) wherever possible. Windows authentication is specified in a connection string by using the Integrated Security or Trusted_Connection keywords, eliminating the need to use a user ID and password. When using Windows authentication, users are authenticated by Windows, and access to server and database resources is determined by granting permissions to Windows users and groups. For situations where it is not possible to use Windows authentication, you must use extra care because user credentials are exposed in the connection string. In an ASP.NET application, you can configure a Windows account as a fixed identity that is used to connect to databases and other network resources. You enable impersonation in the identity element in the web.config file and specify a user name and password. The fixed identity account should be a low-privilege account that has been granted only necessary permissions in the database. In addition, you should encrypt the configuration file so that the user name and password are not exposed in clear text.

Encrypt Configuration Files

You can also store connection strings in configuration files, which eliminates the need to embed them in your application's code. Configuration files are standard XML files for which the .NET Framework has defined a common set of elements. Connection strings in configuration files are typically stored inside the element in the app.config for a Windows application, or the web.config file for an ASP.NET application. For more information on the basics of storing, retrieving and encrypting connection strings from configuration files, see Connection Strings and Configuration Files.

关于c# - 如何在 C# .Net 4.6 WPF 应用程序中隐藏 ConnectionString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32954870/

相关文章:

c# - stringToHex 和 hexToString C# 和 Android Java

c# - 从第二个列表中获取唯一元素

c# - 正则表达式提取数字字符串

java - AES CBC PKCS5Padding Java 到 Ruby

c# - 允许控件正确缩放的布局

c# - 免费 WPF 实时图表

security - 无需硬编码密码即可加密、解密

c# - 比较linq中的日期

c# - FileStream.Seek 与缓冲读取

.net - 选择哪个ui框架