gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:22:20 25 4
gpt4 key购买 nike

我有一个使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com