今天要将一个老的ASP系统加个登陆功能,要求用Blog的用户登陆。
本以为很简单,连个数据库,判断一下就行了,谁知搞得郁闷。博客是Dottext的系统,用户的密码被加密过了。加密函数如下:
public static string Encrypt(string password)
{
// Force the string to lower case
//
password = password.ToLower();
![]()
Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
![]()
return BitConverter.ToString(hashedBytes);
}加密函数先将密码转化为Unicode Byte编码,再用MD5进行加密。
但是ASP中的MD5加密程序,都是用ASCII 码加密,两个函数加密出来的结果是不一样的。
怎么改都不行![]()
后来想了个巨恶心的办法,登陆后先导向一个临时的ASPX页面,将TextBox中的密码用上面的函数进行加密,再传到一个ASP页面,连了数据库,与数据库中的相对应的密码进行比较。![]()
实在是没有办法了,艾......![]()
文章来源:http://blog.handsbrain.com/leezjs/archive/2005/08/06/9315.aspx
本以为很简单,连个数据库,判断一下就行了,谁知搞得郁闷。博客是Dottext的系统,用户的密码被加密过了。加密函数如下:
public static string Encrypt(string password)
{
// Force the string to lower case
//
password = password.ToLower();
Byte[] clearBytes = new UnicodeEncoding().GetBytes(password);
Byte[] hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
return BitConverter.ToString(hashedBytes);
}但是ASP中的MD5加密程序,都是用ASCII 码加密,两个函数加密出来的结果是不一样的。
怎么改都不行
后来想了个巨恶心的办法,登陆后先导向一个临时的ASPX页面,将TextBox中的密码用上面的函数进行加密,再传到一个ASP页面,连了数据库,与数据库中的相对应的密码进行比较。
实在是没有办法了,艾......
文章来源:http://blog.handsbrain.com/leezjs/archive/2005/08/06/9315.aspx

浙公网安备 33010602011771号