Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could put the password into a separate section and encrypt this section only. For example:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt; &lt;/configSections&gt; &lt;appSettings&gt; &lt;add key="Host" value="www.foo.com" /&gt; &lt;add key="Token" value="qwerqwre" /&gt; &lt;add key="AccountId" value="123" /&gt; &lt;add key="DepartmentId" value="456" /&gt; &lt;add key="SessionEmail" value="foo@foo.com" /&gt; &lt;add key="DefaultFolder" value="789" /&gt; &lt;/appSettings&gt; &lt;secureAppSettings&gt; &lt;add key="Password" value="asdfasdf" /&gt; &lt;/secureAppSettings&gt; &lt;/configuration&gt; </code></pre> <p>and then (note that I am using DPAPI in my example so adapt the provider for RSA):</p> <pre><code>aspnet_regiis -pef secureAppSettings . -prov DataProtectionConfigurationProvider </code></pre> <p>Once encrypted the file will look like this:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt; &lt;/configSections&gt; &lt;appSettings&gt; &lt;add key="Host" value="www.foo.com" /&gt; &lt;add key="Token" value="qwerqwre" /&gt; &lt;add key="AccountId" value="123" /&gt; &lt;add key="DepartmentId" value="456" /&gt; &lt;add key="SessionEmail" value="foo@foo.com" /&gt; &lt;add key="DefaultFolder" value="789" /&gt; &lt;/appSettings&gt; &lt;secureAppSettings configProtectionProvider="DataProtectionConfigurationProvider"&gt; &lt;EncryptedData&gt; &lt;CipherData&gt; &lt;CipherValue&gt;AQAAANCMnd.......&lt;/CipherValue&gt; &lt;/CipherData&gt; &lt;/EncryptedData&gt; &lt;/secureAppSettings&gt; &lt;/configuration&gt; </code></pre> <p>The way you would access those settings in your application once the file is encrypted is still the same and completely transparent:</p> <pre><code>var host = ConfigurationManager.AppSettings["Host"]; var password = ConfigurationManager.AppSettings["Password"]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload