大家好,
最近,我正在开发扩展应用程序(.net 2.0)以生成密码,使用MD5加密密码,然后将其插入数据库中,以便在网站(.net 1.1平台)中进行客户端登录。
开发了扩展程序后,我的一些用户报告说某些密码无法在网站上使用。
当我检查编码加密时,发现了一些问题。
这是我加密方法的一部分。
坍方
公共字符串cryptoStr(string strPassword)
{
MD5 md5 =新的MD5CryptoServiceProvider();
byte [] pwd = Encoding.Unicode.GetBytes(strPassword);
字符串ePwd = Encoding.Unicode.GetString(md5.ComputeHash(pwd));
返回ePwd;
}
如果只是在调试模式下运行,请输入“密码”,在Platform .net 1.1和2.0中,字符串值“ ePwd”可能不会有所不同
再次使用“ ePwd”转换为Byte [],您发现“ pwd”与“转换字节值”不同。
这是VS 2003和VS 2008的项目。
From: https://bytes.com/topic/c-sharp/insights/906712-md5-encoding-differ-net-1-1-2-0-a