能不能给个例子啊,我在MSDN中就找到下面的信息: Dim data(DATA_SIZE) As Byte' This is one implementation of the abstract class MD5. Dim md5 As New MD5CryptoServiceProvider()Dim result As Byte() = md5.ComputeHash(data)我有两点不明白: 一:计算出来的结果是什么东西,如何写入数据库? 二:MSDN上说计算结果HashSize以位为单位,可是写入数据库只能以字节为单位,那么用户登陆的时候,对输入的密码用ComputeHash加密,再与数据库比较,还能正确吗?比如加密后HashSize为5位,而数据库中的数据不可能为5位,至少8位,他们之间一比较,正确的密码还能得出正确的结果吗?
要加密的 http://blog.csdn.net/pwqzc 有你要的东西
MD5最简单,但速度最快~~类System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile就Hash加密类,要将密码进行MD5加密这样即可 public string md5PWD(string str) { return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"md5").ToLower(); } 登录时把输入密码再加密一次,和数据库里的纪录匹配一下就行了,不用解密。
__declspec(dllexport) BOOL DeEncryption(BYTE* Pass, int Len)
使用DES吧。
Dim data(DATA_SIZE) As Byte' This is one implementation of the abstract class MD5.
Dim md5 As New MD5CryptoServiceProvider()Dim result As Byte() = md5.ComputeHash(data)我有两点不明白:
一:计算出来的结果是什么东西,如何写入数据库?
二:MSDN上说计算结果HashSize以位为单位,可是写入数据库只能以字节为单位,那么用户登陆的时候,对输入的密码用ComputeHash加密,再与数据库比较,还能正确吗?比如加密后HashSize为5位,而数据库中的数据不可能为5位,至少8位,他们之间一比较,正确的密码还能得出正确的结果吗?
http://blog.csdn.net/pwqzc
有你要的东西
public string md5PWD(string str)
{
return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str,"md5").ToLower();
}
登录时把输入密码再加密一次,和数据库里的纪录匹配一下就行了,不用解密。
.net提供了几个加密类,可根据需要选择.
http://www.chinamacro.com/blog/visit_detail.aspx?blogID=39
http://www.chinamacro.com/blog/visit_detail.aspx?blogID=101