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