Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Option 1: You can protect use <a href="http://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.protectsection%28v=vs.110%29.aspx" rel="nofollow noreferrer">SectionInformation.ProtectSection</a> to encrypt it, or if it's an ASP.NET app you can use aspnet_regiis to encrypt it, iirc aspnet_regiis uses <em>ProtectSection</em> under the covers so in theory you could use this in command line if you wanted on a regular app. Can be done like below, to clear up all the cluttter from msdn article</p> <pre><code>// you will need to add ref to System.Configuration Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Get the section. UrlsSection section = (UrlsSection)config.GetSection("MyUrls"); // Protect (encrypt)the section. section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider"); config.Save(ConfigurationSaveMode.Full); </code></pre> <p>Option 2: Write up your own encryption decryption mechanism, check out <a href="http://msdn.microsoft.com/en-us/library/9eat8fht.aspx" rel="nofollow noreferrer">System.Security.Cryptography</a> to learn how to do this</p> <p>Option 3: Use <a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.protecteddata.aspx" rel="nofollow noreferrer">ProtectData</a> (from System.Security.Cryptography) class to encrypt using user specific or machine specific encryption. This is simple, something like this will do.</p> <pre><code>byte[] aditionalEntropy = {9, 8, 7, 6, 5}; byte[] secret = {0, 1, 2, 3, 4, 1, 2, 3, 4}; byte[] protectedBytes = ProtectedData.Protect(secret, aditionalEntropy, DataProtectionScope.CurrentUser); byte[] originalSecret = ProtectedData.Unprotect(protectedBytes, aditionalEntropy, DataProtectionScope.CurrentUser); </code></pre> <p>Note that method #1 encrypts using the machine key, and therefore can only be read back on the machine it was encrypted thus can be read back by any user running your app on the same machine. Method #3 is based on the user key (and specific to the machine iirc) so is the most restrictive. If you want to encrypt in one machine and make it readable across different machines, you'll need to go with option 2</p>
 

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