This is my get/set method where I encrypt the password:
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password {
set {
var emp = db.Employees.Find(2);
password = EncryptDecrypt.Encrypt(emp.Password, "a15s8f5s6e2s3g1w5");
}
get {
return password;
}
}
I use the following code to allow the user to login and I also use it to decrypt the password:
private Employee slogin;
using (var db = new Entities())
{
var erg = from s in db.Employees
where s.LastName.ToString() == model.UserName && s.Password == EncryptDecrypt.Decrypt(model.Password, "a15s8f5s6e2s3g1w5")
select s;
slogin = erg.FirstOrDefault();
}
Every time when I run the code I get a NotSupportedException here: slogin = erg.FirstOrDefault();
{"LINQ to Entities does not recognize the method 'System.String Decrypt(System.String, System.String)' method, and this method cannot be translated into a store expression."}