如何将passwordHash转换为字符串?字节为字符串散列函数?
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);
}
如果我尝试:
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);
}
当我拿到我的学生收取的密码字段会说System.Byte []其中,因为我想要得到的散列/腌密码了?
所有字符串都可以编码为一个字节序列,但并非所有字节序列都可以解码为一个字符串。 – dtb 2012-04-22 00:11:21
dtb:你是对的,但字符串是字节序列(无论如何,北美)。因此,根据上下文,这个解决方案确实有效。如果有人没有得到理想的结果,那不是因为我错了,而是他们的设计或问题是。 – 2012-04-23 01:19:30