0

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 ?

Community
  • 1
  • 1
Mediator
  • 14,951
  • 35
  • 113
  • 191
  • possible duplicate of [How to encrypt app.config?](http://stackoverflow.com/questions/4330122/how-to-encrypt-app-config) by the same user. – H H Dec 18 '10 at 12:35
  • you just CEP. I already had written. In the last post, I have not helped. – Mediator Dec 18 '10 at 12:57
  • 1
    Google more:) http://stackoverflow.com/questions/42115/app-config-connection-string-protection-error – Simon Dec 18 '10 at 13:13
  • @Simon, "If you're on Vista or above, make sure you're running as administrator." - is helped me. but I can not understand how to use it. Is a C # can do that would run from the administrator? – Mediator Dec 18 '10 at 14:03

2 Answers2

1

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.
Lex Li
  • 60,503
  • 9
  • 116
  • 147
1

Best practice is to do it manualy in your settings class: http://msdn.microsoft.com/en-us/library/system.configuration.rsaprotectedconfigurationprovider.aspx

Simon
  • 3,235
  • 5
  • 36
  • 47