I have a class with a bunch of fields that need to be encrypted before being saved, something like this;
class MyClass
{
public string CustomerName{ get; set; }
public string Address1{ get; set; }
public string Address2{ get; set; }
public string Town{ get; set; }
public string Postcode{ get; set; }
// updated
public DateTime RegistrationDate { get; set; } // don't encrypt
}
What’s the most performant approach to encrypt the fields in this object?
What about if we had to encrypt 100 or 1000 of these objects? (can we leverage TPL?)
UPDATE:
Some of the fields might not need encryption, so I don’t want to encrypt the entire class.
.NET4 is acceptable.
Assuming that you finally want encrypted fields no matter you application layers, you have to time it on your own in order to get results for your system and configuration. In general your can use parallel tasks for compression as in the following sample code:
You can modify the above to cover your needs and perform your own tests.
For the above sample you will need: