Csharp/C#教程:加密非ASP.Net应用程序中的连接字符串分享


加密非ASP.Net应用程序中的连接字符串

我正在使用C#和WPF,当然还有app.config文件。 我无法找到存储在app.config中的加密连接字符串示例。 有很多ASP.NET和web.config的例子,但app.config没什么可靠的。 我遇到的唯一例子清楚地表明字符串在它首次加密的同一台机器上只是“可解码”(即使是一个字?)。 在app.config中使用加密连接字符串(或其他数据)是否有可行的选项?

在App.config中加密ConnectionStrings

上述就是C#学习教程:加密非ASP.Net应用程序中的连接字符串分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

private void ProtectSection(String sSectionName) { // Open the app.config file. Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); // Get the section in the file. ConfigurationSection section = config.GetSection(sSectionName); // 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); } } } 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/949470.html

(0)
上一篇 2021年11月17日
下一篇 2021年11月17日

精彩推荐