如何在应用程序内保存密码(转换为哈希)? [英] How do I save the password (converted to hash) inside the application?

查看:109
本文介绍了如何在应用程序内保存密码(转换为哈希)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于第二部分,我现在添加了从文本文件中读取哈希的代码。但我担心的是我应该在哪里保存这些哈希,以便将它存储在应用程序中。(含义:应用程序将能够在没有文本文件的情况下在同一目录中运行)。



非常感谢任何帮助(仅供参考:我使用的是visual studio)?

For the second portion, I had now added the code to read the hash from the textfile. But my concern is where should I saved these hash into so that it will be stored in the application.(Meaning: the application will be able to run without the textfile in the same directory).

Anyone assistance would be greatly appreciated(FYI: I am using visual studio)?

推荐答案

I我们想知道我们是否有参数 [ ^ ]。
I wonder if we have an article on such an argument[^].


这是错误的方法。您应该将散列密码保存在文件中(app.config是一种可能性)。然后,当有人运行应用程序时,他们输入密码,代码将其转换为哈希值并与保存的值进行比较。
That is the wrong way to do it. You should save the hashed password in a file (app.config is one possibility). Then when someone runs the app they enter the password, the code converts it into a hash and compares with the saved value.


可以有不同的方法将数据保存到文件中。首先,为文件选择正确的位置非常重要。请参阅我以前的回答:如何查找我的程序目录 [ ^ ]。



如何保存和恢复任意数据结构。这是最强大和最全面的方法,也是最容易使用的方法: http://msdn.microsoft .com / zh-CN / library / ms733127.aspx [ ^ ]。



另见我过去的答案:

如何将数据合同从C#/ WCF代码传递给托管C ++ [ ^ ],

如何在我的表单应用程序中使用XML文件编写器和阅读器? [ ^ ],

创建属性文件...... [ ^ ]。



-SA
There can be different ways to save the data in the file. First of all, it's important to choose right location for the file. Please see my past answer: How to find my programs directory[^].

How to save and restore arbitrary data structure. This is the most robust and comprehensive approach, which is also the easiest to use: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

See also my past answers:
how to pass a datacontract from a C#/WCF code to Managed C++[^],
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

—SA


这篇关于如何在应用程序内保存密码(转换为哈希)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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