如何在桌面应用程序中有效保存数据库密码?

发布于 2024-08-19 15:48:35 字数 257 浏览 6 评论 0原文

我正在制作使用数据库(mysql)的桌面应用程序(让我们称之为应用程序)。 多个应用程序的用户共享一个数据库用户。 示例:John 和 Mike 应用程序用户以“dbuser”等身份连接到数据库。

问题是:如何有效地保存数据库用户的密码?(应用程序用户的密码存储在数据库中)。

我发现的可能的解决方案: 1. 在代码中 - 这实际上非常愚蠢:D 2.在文本INI文件中——易于阅读! 3.在外部文件中加密-很好,但需要访问应用程序。

I'm making desktop application (lets call it app) which uses database (mysql).
More app's users share one database user.
Example : John and Mike app users connect to DB as "dbuser", etc.

The problem is : How do I effectively save passwords for DB users? (app users's pwds are stored in DB).

Possible solutions I found :
1. in the code - this is actually pretty stupid :D
2. in the text INI file - easy to read!
3. encrypted in extern file - good, but need access to app.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

以可爱出名 2024-08-26 15:48:35

(应用程序用户的密码存储在数据库中)。

使用 SHA1/SHA2 算法加密存储的密码。这是最常用的技术。
我不是 .NET 开发人员,但我很确定他们在某个地方提供了该功能。

当用户登录时,再次加密给定的密码并将其与存储的密码进行比较。如果相等,则让用户登录。

(app users's pwds are stored in DB).

Encrypt stored passwords using SHA1/SHA2 algorithm. This is the most used technique.
I'm not a .NET developer but I'm pretty sure that they provide the function somewhere.

When user logs in, encrypt again the given password and compare it to the stored one. If they are equal, let the user log in.

浮萍、无处依 2024-08-26 15:48:35

您可以将其以加密格式存储在 INI 文件中。恕我直言,这是最好的方法。我以加密格式将连接字符串存储在.NET应用程序的App.config中。

编辑:

要编辑连接字符串,我在 App.Config 文件 CSEncryption="Y|N|R" 的 AppSettings 中使用另一个配置值,

如果它是 Y,则连接字符串已加密,解密并使用它。

如果为N,则连接字符串未加密,直接使用。

如果是 R,则连接字符串未加密,请对其进行加密并更新连接字符串,并在 App.Config 中将 CSEncryption 设置为“Y”。

You can store it in the INI file in the encrypted format. That is best way IMHO. I stores connection string in the App.config of .NET application in the encrypted format.

EDIT:

To edit connection string, I use another configuration value in AppSettings of App.Config file CSEncryption="Y|N|R"

if it is Y, connection string is encrypted, decrypt and use it.

if it is N, connection string is not encrypted, use it directly.

if it is R, connection string is not encrypted, encrypt it and update connection string and set CSEncryption to 'Y' in App.Config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文