Baybars Bay

Baybars Bay

  • 1.7k
  • 88
  • 3.7k

Saving asp.net encrypted password to sql database

Nov 28 2020 11:22 AM
.
I want to save the password in the asp.net user registration form in an encrypted format to the sql database.

I'm waiting for your help
public ActionResult InsertDetails()
{
return View();
}
// Calling on http post (on Submit)
[HttpPost]
public ActionResult InsertDetails(Register obj)
{
Register objreg = new Register();
string result = objreg.InsertRegDetails(obj);
ViewData["result"] = result;
ModelState.Clear();
return RedirectToAction("Index", "Photos");
}
-----My model-----
public class Register
{
public int User_ID { get; set; }
public string UserPicturePath { get; set; }
public string E_Mail { get; set; }
public string User_Name { get; set; }
public string Password { get; set; }
public Nullable<System.DateTime> DateBirth { get; set; }
public string Country { get; set; }
public string City { get; set; }
public string MentionAbout { get; set; }
public Nullable<System.DateTime> CreationDate { get; set; }
SqlConnection con = new SqlConnection("Server=.;Database=IMAGESBILBOARD;Trusted_Connection=True;");
SqlCommand cmd = new SqlCommand();
public string InsertRegDetails(Register obj)
{
cmd.CommandText = "Insert into [UsersInfo] values('" + obj.UserPicturePath + "','" + obj.E_Mail + "','" + obj.User_Name + "','" + obj.Password + "','" + obj.DateBirth + "','" + obj.Country + "','" + obj.City + "','" + obj.MentionAbout + "','" + obj.CreationDate + "')";
cmd.Connection = con;
try
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
return "Success";
}
catch (Exception es)
{
throw es;
}
}
}

Answers (1)