I have this POCO class:
class Users
{
public string User { get; set; }
public string Password { get; set; }
private string Encrypt(string plainText)
{
...
return encryptedText;
}
private string Decrypt(string cipherText)
{
...
return decryptedText;
}
How can I do to Encrypt/Decrypt Password
field when I read data from my database and when I access my POCO object from C#?
I'm tried to use sometingh like this:
class Users
{
private string _password;
public string User { get; set; }
public string Password
{
get
{
return Encriptar(_password);
}
set
{
_password = Desencriptar(value);
}
}
private string Encrypt(string plainText)
{
...
return encryptedText;
}
private string Decrypt(string cipherText)
{
...
return decryptedText;
}
But when the objects are filled with data from my database, all is ok, the Password
field decrypts correctly, but when I access an object from C# to show in text field, the get
property enrypts again my data :/