How can I convert passwordHash to string?
public void AddStudent(Student student)
{
student.StudentID = (++eCount).ToString();
byte[] passwordHash = Hash(student.Password, GenerateSalt());
student.Password = passwordHash; //this line?
student.TimeAdded = DateTime.Now;
students.Add(student);
}
If I try:
public void AddStudent(Student student)
{
student.StudentID = (++eCount).ToString();
byte[] passwordHash = Hash(student.Password, GenerateSalt());
student.Password = Convert.ToString(passwordHash); //this line?
student.TimeAdded = DateTime.Now;
students.Add(student);
}
When I GET my Student collection the password field will say System.Byte[] where as I want to get the hashed/salted password back?
You can use the Convert.ToBase64String Method: