views:

31

answers:

2

Is it possible to encrypt a single value or must you encrypt entire sections?

I.e. Given the app.config below can how can I encrypt just the password. I've read articles on encrypting connection string sections and whole sections of app.config.

<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="Interval" value="40000" />
<add key="User" value="User1" />
<add key="Password" value="boombox" />    ...

If you have any suggestions they would be greatly appreciated

A: 

You have to encrypt/decrypt before saving/after loading the settings file. Look at the System.Security.Cryptography Namespace. I used the DES provider to read/write a password into the settings file.

testalino
A: 

You can encrypt a password in an app.config by using DPAPI.

dhirschl