.net core 加密.NET Core 2中的ConnectionString部分
传统上,我会使用下面这样的.net core 加密.NET Core 2中的ConnectionString部分,.net-core,connection-string,.net Core,Connection String,传统上,我会使用下面这样的 // Open the configuration file and retrieve // the connectionStrings section. Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName); ConnectionStringsSection se
// Open the configuration file and retrieve
// the connectionStrings section.
Configuration config = ConfigurationManager.OpenExeConfiguration(exeConfigName);
ConnectionStringsSection section = config.GetSection("connectionStrings") as ConnectionStringsSection;
if (section.SectionInformation.IsProtected)
{
// Remove encryption.
section.SectionInformation.UnprotectSection();
}
else
{
// Encrypt the section.
section.SectionInformation.ProtectSection(
"DataProtectionConfigurationProvider");
}
// Save the current configuration.
config.Save();
是否有一种方法可以在.NET Core 2中使用,并将ConnectionString存储在appSettings.json中