I have Model named Users in ASP.NET MVC 5. I have Encrypt() and Decrypt() Extension Methods to Encrypt and Decrypt string respectively. I want to encrypt and decrypt data while sving and fetching from database. So, I used:
private string _mob;
public string mob
{
get
{
return _mob.Decrypt();
}
set
{
_mob = value.Encrypt();
}
}
But I am unable to achieve my goal. When I use
public string mob
{
get
{
return _mob;
}
set
{
_mob = value.Encrypt();
}
}
I get encryption done but as soon as I add Decrypt() in get{} there is no encryption/decryption done. I see plain text data in database.