(If this is a duplicate post, please point me to the original or tell me what to search for. I could not find anything. Thank you!)
So, I have an encrypted value saved in a database row. I want to retrieve the column values for the database row and store them in a class instance. Is it safe to create a public property on the class for the DECRYPTED value?
public class *DataRow*
{
public string *DataElement* { get; set; }
public string *Value_Decrypted* { get; set; }
}
Can an external process somehow access the public property? Do I need to use SecureString (or something else) to protect against memory hacks? Does .NET's DataProtection help with any of this?
Is there a practical guide/walkthrough somewhere for how to handle this (hopefully without too much coding overhead)?
These feel like pretty basic questions (ashamed), and I have heard talk about these concerns, but in my searching I could not find anything. Wasn't sure what to search for (other than what's in the Title of this post).
As always, any direction will be greatly appreciated.
Thank you!
EDIT:
Thank you everyone for the responses. Password was a BAD example--I understand it is ill advised and usually unnecessary to decrypt a password. I guess my question is more general, relative to how to handle data that does need to be decrypted. I have updated my example to reference an encrypted/decrypted value instead of a password.
I am writing a generic monitor program and need to save access values, paths and commands in a database. I feel it's best to encrypt these values in an effort to minimize exposure of our infrastructure, etc.
The consensus seems to be that saving the decrypted value in any form, property or otherwise, is a bad idea.
I am now thinking that I will store only the encrypted value and then decrypt it, using a SecureString, every time I need it.
Thank you all again!!