age*_*t47 7 c# security asp.net-mvc forgot-password password-recovery
您建议以哪种方式在和中创建安全密码重置链接?我的意思是,我会创建一个随机令牌,对吧?如何在发送给用户之前对其进行编码?是MD5不够好?你知道其他任何安全方式吗?MVCC#
Dai*_*Dai 18
使用System.Security.Cryptography.RandomNumberGenerator哪种是加密安全的RNG.只需将其包含在电子邮件中,并将其存储在数据库中以便以后检索.我没有看到散列它的重点.
它在此处记录:http://msdn.microsoft.com/en-us/library/system.security.cryptography.randomnumbergenerator.aspx
using System.Security.Cryptography;
using( RandomNumberGenerator rng = new RandomNumberGenerator() ) {
Byte[] bytes = new Byte[12]; // Use a multiple of 3 (e.g. 3, 6, 12) to prevent output with trailing padding '=' characters).
rng.GetBytes( bytes );
String sendThisInEmailAndStoreInDB = Convert.ToBase64String( bytes );
}
Run Code Online (Sandbox Code Playgroud)
我认为您不需要为此目的使用加密字符串。我认为用Guid创建一个字符串就足够了。
string thatString=Guid.NewGuid("n").ToString();
Run Code Online (Sandbox Code Playgroud)
将其保存在针对该特定用户帐户的数据库表中。为具有此字符串的用户创建一个链接并将其发送给他们。当他们单击它时,他们将进入一个操作方法,您将获得与我们存储的临时字符串关联的相应用户记录,并显示用户更新密码的表单。
如果您怀疑 Guid 是否唯一,请查看此。