大家好,谁能告诉我如何在全球范围内存储用户ID和密码 [英] Hi guys can anyone tell me how can i store the User Id and password globely

查看:49
本文介绍了大家好,谁能告诉我如何在全球范围内存储用户ID和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,谁能告诉我如何在全球范围内存储用户ID和密码以在窗口应用程序的每种表单中显示用户名..

在此先感谢

解决方案

首先,永远不要在任何地方存储密码.这是不安全的.身份验证永远不需要密码.这不是很明显吗?提示:您可以使用加密散列函数,请参阅:
http://en.wikipedia.org/wiki/Cryptographic_hash_function [ http://en.wikipedia.org/wiki/Md5 [ http://en.wikipedia.org/wiki/SHA-1 [ http://en.wikipedia.org/wiki/SHA-2 [ http://msdn.microsoft.com/en-us/library/system. security.cryptography.hashalgorithm.aspx [ ^ ].

现在,在哪里存储它和用户名? .NET中没有全局"的概念(谢天谢地!终于!).您可以使用单人模式,请参见:
http://en.wikipedia.org/wiki/Singleton_pattern [ http://csharpindepth.com/Articles/General/Singleton.aspx [ 解决方案

First, you should never store a password anywhere, ever. This is unsafe. Authentication never needs a password. Isn''t this obvious? A hint: you can use a cryptographic hash function, please see:
http://en.wikipedia.org/wiki/Cryptographic_hash_function[^].

Compare hash with a hash, never an original form of a password. Nobody should ever know it except the owner of it, the user.

Now, don''t use MD5 or SHA-1 algorithms; they are unsafe. For example, use one from SHA-2 family. Please see:
http://en.wikipedia.org/wiki/Md5[^],
http://en.wikipedia.org/wiki/SHA-1[^],
http://en.wikipedia.org/wiki/SHA-2[^].

They are well implemented in .NET, please see:
http://msdn.microsoft.com/en-us/library/system.security.cryptography.hashalgorithm.aspx[^].

Now, where to store it and the user names? There are no a concept of "global" in .NET (thanks goodness! finally!). You can use the singleton pattern, please see:
http://en.wikipedia.org/wiki/Singleton_pattern[^].

A correct .NET implementation is shown here:
http://csharpindepth.com/Articles/General/Singleton.aspx[^].

—SA


Hehe...are you using a database? or just to make things simple write them to a file then read them when you want. Stream Writer and Stream Reader


store in session and set the session time out more an more in web.config file.becuase the session value you can access in each and every form


这篇关于大家好,谁能告诉我如何在全球范围内存储用户ID和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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