我使用以下代码进行用户注册。当我调试代码时,密码是加密形式,但它存储为纯文本。密码盐也存储在数据库中。
[HttpPost, RecaptchaControlMvc.CaptchaValidator]
public ActionResult Register(Authentication reg, bool captchaValid, string captchaErrorMessage)
{
if (!captchaValid)
ModelState.AddModelError("captcha", captchaErrorMessage);
if (ModelState.IsValid)
{
Registeration register = new Registeration();
var crypto = new SimpleCrypto.PBKDF2();
//string encrypPass = crypto.Compute(reg.Password);
//var length = encrypPass.Length;
register.FirstName = reg.FirstName;
register.LastName = reg.LastName;
register.Email = reg.Email;
register.Password = crypto.Compute(reg.Password);
reg.PasswordSalt = crypto.Salt;
db.Authentications.InsertOnSubmit(reg);
db.SubmitChanges();
}
return View();
}
任何帮助将不胜感激。谢谢!