ASP.NET 4
I’ve used RSA key encryption for connection strings in web.config on my web farm. However, there’s one more custom password entry that I’d like to encrypt. How should I encrypt it with RSA key without having the rest configurations being encrypted. Please advise, thanks.
Example:
<appSettings>
...
<add key="Host" value="www.foo.com" />
<add key="Token" value="qwerqwre" />
<add key="AccountId" value="123" />
<add key="DepartmentId" value="456" />
<add key="Password" value="asdfasdf" />
<add key="SessionEmail" value="foo@foo.com" />
<add key="DefaultFolder" value="789" />
</appSettings>
You could put the password into a separate section and encrypt this section only. For example:
and then (note that I am using DPAPI in my example so adapt the provider for RSA):
Once encrypted the file will look like this:
The way you would access those settings in your application once the file is encrypted is still the same and completely transparent: