我正在使用System.Configuration来加密和保护自定义配置部分vis:-中的某些密码。
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);
}
这似乎工作正常,但我的文档需要一些其他信息。
key 存储在哪里?
key 多长时间?
最佳答案
用户级别的 key 存储在
机器级 key 位于
您的是用户级别的 key 。