1
任何人都可以帮助我解决一些问题。我正在尝试创建一个自制的身份验证方法,我只是在几个方面陷入困境,并希望有人能够提供帮助。我想问的第一件事是如何解决我在代码注释的问题:byte []不包含SequenceEqual认证方法的定义
public string Authentication(string studentID, string password)
{
var result = students.FirstOrDefault(n => n.StudentID == studentID);
//find the StudentID that matches the string studentID
if (result != null)
//if result matches then do this
{
//----------------------------------------------------------------------------
byte[] passwordHash = Hash(password, result.Salt);
string HashedPassword = Convert.ToBase64String(passwordHash);
//----------------------------------------------------------------------------
// take the specific students salt and generate hash/salt for string password (same way student.Passowrd was created)
System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
byte[] UserPassword = enc.GetBytes(HashedPassword);
UserPassword.SequenceEqual(result.Password); // byte[] does not contain a definition for SequenceEqual?
//check if the HashedPassword (string password) matches the stored student.Password
}
return result.StudentID;
//if string password(HashedPassword) matches stored hash(student.Passowrd) return student list
//else return a message saying login failed
}
AHHH宾果上返回result.StudentID解决了,如果我删除括号tho整行是错误的 – 2012-04-24 09:07:56
它说byte []不包含序列相等?下半场我可能会弄清楚,如果我得到了第一点的工作。只是想展示我的想法。 – 2012-04-24 09:10:06
@JungleBoogie听起来像是下一个错误。我无法帮助。用示范问题的示例创建一个新问题。 – 2012-04-24 09:10:52