0

我尝试使用下面的代码进行加密,但它只能在我的 PC 上使用,其他 PC 无法连接到我 PC 中的 SQL Server。有人帮我吗?非常感谢!!!(我也尝试使用 aspnet_regiis.exe 但有同样的问题)

        public static void ProtectSection(String sSectionName)
    {
        Configuration config = ConfigurationManager.OpenExeConfiguration("TFLManager.exe");

        // Get the section in the file.
        ConnectionStringsSection section = config.GetSection(sSectionName) as ConnectionStringsSection;
        // If the section exists and the section is not readonly, then protect the section.
        if (section != null)
        {
            if (!section.IsReadOnly())
            {
                // Protect the section.
                section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
                section.SectionInformation.ForceSave = true;
                // Save the change.
                config.Save(ConfigurationSaveMode.Modified);
            }
        }
    }
4

1 回答 1

0

在您想要的计算机上以管理员身份启动命令提示符。在命令提示符处,输入:

 cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

如果您的 Web Config 位于“D:\Code\EncryptWebConfig”目录路径中,则输入以下内容以加密 ConnectionString:

ASPNET_REGIIS -pef "connectionStrings" "D:\Code\EncryptWebConfig"
于 2018-05-13T06:21:40.090 回答