加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用RsaProtectedConfigurationProvider进行ProtectSectio

发布时间:2020-12-15 06:47:39 所属栏目:百科 来源:网络整理
导读:我正在使用System.Configuration加密和保护自定义配置部分中的一些密码: – . static public void SetPassAndProtectSection(string newPassword){ // Get the current configuration file. System.Configuration.Configuration config = ConfigurationMana
我正在使用System.Configuration加密和保护自定义配置部分中的一些密码: – .
static public void SetPassAndProtectSection(string newPassword)
{

    // Get the current configuration file.
    System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);


    // Get the section.
    MyAppProtectedSection section = 
        (MyAppProtectedSection)config.GetSection(DEFAULT_SECTION_NAME);

    section.DBPassword = newPassword;

    // Protect (encrypt)the section.
    section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");

    // Save the encrypted section.
    section.SectionInformation.ForceSave = true;

    config.Save(ConfigurationSaveMode.Full);
}

这似乎工作正常,但我需要一些额外的信息为我的文档.

密钥存储在哪里?

钥匙多长时间?

迈克尔

解决方法

用户级别的密钥存储在

Documents and
Settings{UserName}Application
DataMicrosoftCryptoRSA

机器级键在

Documents and SettingsAll
UsersApplication
DataMicrosoftCryptoRSAMachineKeys

您的用户级密钥.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读