vb.net连接实体框架连接字符串安全性

vb.net连接实体框架连接字符串安全性,vb.net,winforms,connection-string,app-config,ado,Vb.net,Winforms,Connection String,App Config,Ado,我了解在.NETV4中加密连接字符串的可能性。我有一个win forms应用程序,将由不同机器上的多人使用。我知道我需要在应用程序首次在目标机器上运行时保护连接字符串。但是,我担心在一段时间内,我的连接字符串将不加密。我正在寻找有关如何部署连接字符串已加密或在安装过程中已加密的应用程序的建议 其他人如何以安全的方式加密连接字符串 非常感谢您的帮助 您可以获取connectionString配置部分,如下所示: oSection = oConfiguration.GetSection("conne

我了解在.NETV4中加密连接字符串的可能性。我有一个win forms应用程序,将由不同机器上的多人使用。我知道我需要在应用程序首次在目标机器上运行时保护连接字符串。但是,我担心在一段时间内,我的连接字符串将不加密。我正在寻找有关如何部署连接字符串已加密或在安装过程中已加密的应用程序的建议

其他人如何以安全的方式加密连接字符串


非常感谢您的帮助

您可以获取connectionString配置部分,如下所示:

oSection = oConfiguration.GetSection("connectionStrings") as System.Configuration.ConnectionStringsSection;

if (oSection != null)
{
    if ((!(oSection.ElementInformation.IsLocked)) && (!(oSection.SectionInformation.IsLocked)))
    {
        if (protect)
        {
            if (!(oSection.SectionInformation.IsProtected))
            {
                blnChanged = true;

                // Encrypt the section.
                oSection.SectionInformation.ProtectSection
                            (strProvider);
            }
        }
        else
        {
            if (oSection.SectionInformation.IsProtected)
            {
                blnChanged = true;

                // Remove encryption.
                oSection.SectionInformation.UnprotectSection();
            }
        }
    }

    if (blnChanged)
    {
        // Indicates whether the associated configuration section 
        // will be saved even if it has not been modified.
        oSection.SectionInformation.ForceSave = true;

        // Save the current configuration.
        oConfiguration.Save();
    }
}
:

您可以在应用程序安装期间使用此代码(以检查配置是否受保护),并且可以在应用程序运行期间每次都进行检查

更新:

关于评论中的问题-您可以使用空连接字符串分发应用程序,在安装过程中,设置此属性(在本例中不要忘记代码混淆)并保存配置文件。

您可以获得connectionString配置部分,如下所示:

oSection = oConfiguration.GetSection("connectionStrings") as System.Configuration.ConnectionStringsSection;

if (oSection != null)
{
    if ((!(oSection.ElementInformation.IsLocked)) && (!(oSection.SectionInformation.IsLocked)))
    {
        if (protect)
        {
            if (!(oSection.SectionInformation.IsProtected))
            {
                blnChanged = true;

                // Encrypt the section.
                oSection.SectionInformation.ProtectSection
                            (strProvider);
            }
        }
        else
        {
            if (oSection.SectionInformation.IsProtected)
            {
                blnChanged = true;

                // Remove encryption.
                oSection.SectionInformation.UnprotectSection();
            }
        }
    }

    if (blnChanged)
    {
        // Indicates whether the associated configuration section 
        // will be saved even if it has not been modified.
        oSection.SectionInformation.ForceSave = true;

        // Save the current configuration.
        oConfiguration.Save();
    }
}
:

您可以在应用程序安装期间使用此代码(以检查配置是否受保护),并且可以在应用程序运行期间每次都进行检查

更新:

关于评论中的问题-您可以使用空连接字符串分发应用程序,在安装过程中,设置此属性(在本例中不要忘记代码混淆)并保存配置文件。

如果允许使用该应用程序的用户看到连接字符串,是否可以?还是应该对他们保密?为什么这个问题被否决了?请在投票时留下评论。对我来说,这似乎是一个好问题。如果允许使用该应用程序的人看到连接字符串,可以吗?还是应该对他们保密?为什么这个问题被否决了?请在投票时留下评论。这对我来说是个好问题。谢谢你的回答。有点离题,但您会使用哪种类型的安装程序来分发使用安装程序保护连接字符串的应用程序?Thanks@WizardsSleeve更新了问题。谢谢你的回答。有点离题,但您会使用哪种类型的安装程序来分发使用安装程序保护连接字符串的应用程序?Thanks@WizardsSleeve更新了问题。