简体   繁体   中英

How to encrypt config file ? desktop .NET

Please give me a working example. I have already created a topic, but I'm not there who are not helped How to encrypt app.config? . Or am I just not what is not understood. Once again, I beg you give 100% working example.

I need to encrypt connectString to access the DB mysql.

is an example http://www.c-sharpcorner.com/UploadFile/yougerthen/306132008064100AM/3.aspx . There are two ways the first I have an error. Second, I do not understand how to use

Do not write a lot of text, I do not understand very well. I'm Russian.

UPDATE: I decided to use http://msdn.microsoft.com/en-us/library/system.configuration.rsaprotectedconfigurationprovider.aspx .

But I have an error: "Failed to encrypt the section 'connectionStrings' using provider 'RsaProtectedConfigurationProvider'. The error message from the provider: The object already exists."

I Create App WPF. Append file app.config.

app.config body:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="myconnect"
            connectionString="myConnectString" />
    </connectionStrings>
</configuration>

What do I do next ?

Do this in your installer,

  1. rename app.config to web.config.
  2. Use ASP.NET way to encrypt the data you want to encrypt.
  3. Rename it back to what.exe.config.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM