Hi All,
I tried to use an example of the following link:
http://stackoverflow.com/questions/3067679/creating-a-login-form-and-validating-inputs-in-c-sharp-using-linq-to-sql
but i faced a little problem in using HashPassword.
In the below code, the
.PasswordHash;
right after the .Single(), it shows error that using directive missing something like this, can anyone tell me how to overcome this problem.
Am i missing any using directive? (I used using system.security.cryptography in the namespace)
bool ValidateLogin(DataClasses1DataContext context,string user,string password){byte[] providedPasswordHash = hashPassword(password);byte[] expectedPasswordHash = context.Users.Where(u => u.Name== user).Single().PasswordHash;if(providedPasswordHash.Length!= expectedPasswordHash.Length)returnfalse;for(int i =0; i < providedPasswordHash.Length; i++)if(providedPasswordHash[i]!= expectedPasswordHash[i])returnfalse;returntrue;}byte[] hashPassword(string password){System.Security.Cryptography.SHA1CryptoServiceProvider hasher =newSystem.Security.Cryptography.SHA1CryptoServiceProvider();return hasher.ComputeHash(System.Text.Encoding.UTF8.GetBytes(password));}