Suppose we have a table for such accounts.

Then you can create some helper class that returns an account object
private static Account GetByName(string accountName, bool activatedOnly = false)
{
using (var context = new DBEntities())
{
return context.Accounts.FirstOrDefault(s =>
s.AccountName == accountName &&
s.IsApproved == activatedOnly);
}
}
public static Account Get(string accountName, string password)
{
var account = GetByName(accountName, true);
if (account != null)
if (!Cryptographer.IsValidPassword(password,
account.PasswordSalt,
account.PasswordKey))
return null;
return account;
}
EntityFramework, . - , ( ).
Cryptographer
public class Cryptographer
{
private const int keyByteLength = 20;
public static void Encrypt(string password,
out byte[] salt,
out byte[] key)
{
using (var deriveBytes = new Rfc2898DeriveBytes(password,
keyByteLength))
{
salt = deriveBytes.Salt;
key = deriveBytes.GetBytes(keyByteLength);
}
}
public static bool IsValidPassword(string password,
byte[] salt,
byte[] key)
{
using (var deriveBytes = new Rfc2898DeriveBytes(password, salt))
{
byte[] newKey = deriveBytes.GetBytes(keyByteLength);
return newKey.SequenceEqual(key);
}
}
}
.