2010-04-06 2 views

답변

0

구성 파일이 이상적인 장소가 될 것입니다 조금 더 가서 당신의 web.config의 appSettings는 암호화 할 수 있습니다 asp.net에서 asp.net에서 webconfig 파일의 특정 섹션을 암호화 할 수 있습니다 .Encyption은 aspnet_regiis.exe 유틸리티를 사용하여 관련 명령 줄 인수를 제공하여 수행 할 수 있습니다. 또한 "WebConfigurationManager"클래스의 도움으로 코드를 통해 수행 할 수 있습니다. 해당 섹션의 구성 설정을 읽으려면 섹션의 보호를 해제 할 필요가 없습니다. 런타임은 응용 프로그램이 일반 텍스트 값을 읽는 데 필요한 암호 해독을 수행합니다.

예컨대 : - 여기

C:\>aspnet_regiis -pdf "connectionStrings" "C:\Projects\My Site" 

PDF 인수는 파일 경로를 지정하는 데 사용됩니다 다음 aspnet_regiis.exe.

예컨대 : - 충분 web.conf WebConfigurationManager

protected void toggleEncryption(object sender, EventArgs e) 
{ 
    Configuration config; 
    config = WebConfigurationManager.OpenWebConfiguration("~"); 
    ConnectionStringsSection section; 
    section = config.GetSection("connectionStrings") 
     as ConnectionStringsSection; 
    if (section.SectionInformation.IsProtected) 
    { 
     section.SectionInformation.UnprotectSection(); 
    } 
    else 
    { 
     section.SectionInformation.ProtectSection(
      "DataProtectionConfigurationProvider"); 
    } 
    config.Save(); 
    WriteMessage("connections protected = " + 
    section.SectionInformation.IsProtected); 
} 
관련 문제