我已經使用下面的代碼進行用戶註冊。當我調試密碼是加密形式,但它存儲爲純文本。密碼鹽也已存儲在數據庫。加密密碼不是保存在數據庫,但只有鹽密碼
[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();
}
任何幫助將不勝感激。謝謝!
'register'被添加或保存到數據庫的位置?看來你是爲'reg'做的。 –
如何將註冊添加到數據庫? – Wasfa