Я написал имя своей базы данных, имени пользователя и пароля в моем web.config
файл как строка подключения.
Я хочу зашифровать эти данные. Как я могу сделать это?
<connectionStrings>
<add name="ISP_ConnectionString" connectionString="Data Source=JIGAR;
Initial Catalog=ISP;Integrated Security=True;
User ID=jigar;Password=jigar123;
providerName="System.Data.SqlClient" />
</connectionStrings>
В одном конкретном приложении при запуске я вызываю следующую процедуру:
Private Sub CheckConfigFile()
Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim sec As ConfigurationSection = config.AppSettings
If sec IsNot Nothing Then
If sec.SectionInformation.IsProtected = False Then
Debug.Write("Encrypting the application settings...")
sec.SectionInformation.ProtectSection(String.Empty)
sec.SectionInformation.ForceSave = True
config.Save(ConfigurationSaveMode.Full)
Debug.WriteLine("done!")
End If
End If
End Sub