首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VisualStudio installer未显示

VisualStudio installer未显示
EN

Stack Overflow用户
提问于 2014-10-19 01:26:46
回答 1查看 350关注 0票数 0

我已经安装了VS2013专业版,制作了一个应用程序并想部署它,但问题是,"Visual Installer“似乎不在那里,我也不想要"ClickOnce”。

还有一件事是数据库信息在app.config中,我怎么才能让别人看不到数据库信息呢?

EN

回答 1

Stack Overflow用户

发布于 2014-10-19 12:58:27

关于加密app.config文件的第二个问题的答案相当简单且易于使用:

Protected Configuration Provider帮助对配置文件的各个部分进行加密,以保护应用程序的敏感信息。这将导致应用程序难以让攻击者获取敏感信息。.NET框架提供了两种保护配置提供者的方式:

  1. RSAProtectedConfigurationProvider:这使用Windows加密配置sections
  2. DPAPIProtectedConfigurationProvider:这使用RSACryptoServiceProviderto数据保护API (DPAPI)来加密配置部分。

static void Main(string[] args) { string userNameWithoutEncryption = ConfigurationManager.AppSettings"username";EncryptAppSettings("appSettings");string userNameWithEncrytionApplied = ConfigurationManager.AppSettings"username";}私有静态空EncryptAppSettings(string EncryptAppSettings){ Configuration objConfig =ConfigurationManager.AppSettings+“objConfig”);如果ConfigurationManager.AppSettings{EncryptAppSettings},则objConfig=AppKeyEncryption.exeobjAppsettings.SectionInformation.ForceSave = true;System.Reflection.Assembly.GetExecutingAssembly().GetModules();}}私有静态字符串location (){ System.Reflection.Module[]模块= objConfig.Save(ConfigurationSaveMode.Modified);string GetAppPath= System.IO.Path.GetDirectoryName(modules.FullyQualifiedName);if ((location != "") && (locationlocation.Length -1 != '\')) location += '\';return location;}

要解密app.config文件,需要调用此方法:

代码语言:javascript
复制
    private static void DecryptAppSettings(string section)
    {
        Configuration objConfig = ConfigurationManager.OpenExeConfiguration(GetAppPath() + "AppKeyEncryption.exe");
        AppSettingsSection objAppsettings = (AppSettingsSection)objConfig.GetSection(section);
        if (objAppsettings.SectionInformation.IsProtected)
        {
            objAppsettings.SectionInformation.UnprotectSection();
            objAppsettings.SectionInformation.ForceSave = true;
            objConfig.Save(ConfigurationSaveMode.Modified);
        }
    }

在上面的章节中,描述了如何对配置文件进行加密,以保护密码等敏感信息。现在,如果我们想要更改密钥值,比如密码,在一段时间后,因为我们的配置文件是加密的,我们不能很容易地更新密码。无需担心,.NET框架提供了如下方法:

代码语言:javascript
复制
    private static void UpdateKey(string newValue)
    {
        ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
        configFile.ExeConfigFilename = ConfigurationManager.AppSettings["configPath"];
        Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);
        config.AppSettings.Settings["password"].Value = newValue;
        config.Save();
    }

关于更多信息,这里是我找到这个解决方案并亲自测试它的地方:http://www.a2zmenu.com/blogs/csharp/how-to-encrypt-configuration-file.aspx

我希望这对你有帮助,它对我有用!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26442551

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档