Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encrypt username and password in Web.config in C# 2.0

I have the entries below in my Web.config and I am using .NET 2.0 and C# for coding.

 <add key="userName" value="s752549"/>
 <add key="userPassword" value="Delhi@007"/>

Now I want this to be encrypted so that nobody can see it, and also these passwords may change frequently (every fifteen days).

like image 543
Manoj Singh Avatar asked Jun 09 '11 10:06

Manoj Singh


People also ask

How do I encrypt my username and password?

If you send the encryption key from the server to the client or the other way around you need to encrypt your symmetric encryption key. The easiest way to do this would be to use TLS. If you use TLS, then the data as well as key are encrypted, so you don't need to encrypt it yourself.

How do I encrypt a section of Web config?

Encrypting a Web Configuration Section To encrypt configuration file contents, use the Aspnet_regiis.exe tool with the –pe option and the name of the configuration element to be encrypted. Use the –app option to identify the application for which the Web.


1 Answers

Just wanted to add to this, the marked answer was 99% complete, but it didn't provide how to specify the location of the web config. Rather than root around the internet, thought I'd just post the complete command. As such, here is the command I executed

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -pef "secureAppSettings" "C:\MyLocalPublishDirectory\MyApp" -prov DataProtectionConfigurationProvider
like image 193
ewitkows Avatar answered Oct 06 '22 11:10

ewitkows