What is the best solution to not have a password for a database connection string for example in a config file, or a mail account password to send mails automatically ?
Thanks
What is the best solution to not have a password for a database connection string for example in a config file, or a mail account password to send mails automatically ?
Thanks
You may use encription, but the password has to be stored somewhere. If you're using SQL server, use Windows authentication instead
It doesn't matter where you save it, but I would save it somewhere inside the code (hardcoded) and then encrypt the password AND the user with (example) AESThenHMAC, which i personally like very much.
However, this method of encryption, needs a master key, which may be caught using a reflector.
To counter the reflector, you should obfuscate your code which makes your methods/variables/constants etc harder to read.
But, keep in mind that nothing is 100% secure, but this way you prevent the common curious from getting your credentials.
If someone really wants to get those credentials, and has the knowledge and access to the dll's, he may get it and you are only making him to waste more time.
Free obfuscation tools (.NET) (Source):
You can use a password manager such as Passwordstate (from https://www.clickstudios.com.au).
Your credentials are stored securely in an on-premises server, and you access them via a REST API. All that you have in your code is the information to access the REST API, and if you're paranoid about having even that in your code then you could encrypt it.