0

Entity Frameworkパスワードを使用してデータベースの SQLServer 接続を作成するために使用しています。

connectionString="DataSource=|DataDirectory|DB.sdf;Password=abc

Entity Framework の使用中にパスワードを保護するにはどうすればよいですか?

4

3 に答える 3

1
    ConnectionStringsSection oSection = Configuration.ServiceConfiguration.GetConnectionStrings();
    if(!oSection.SectionInformation.IsLocked && !oSection.SectionInformation.IsProtected)
    {
        oSection.SectionInformation.ProtectSection("RSAProtectedConfigurationProvider"); 
        oSection.CurrentConfiguration.Save();
    }
于 2012-09-04T10:23:43.057 に答える
0

EncDecHelper.Decryptここからのサンプルを使用して書くことができます: .NETの文字列の暗号化/復号化

ここから関連情報を見つけることができます:App.configでパスワードを暗号化する

于 2012-09-04T10:34:30.593 に答える
0

サーバーにアクセスできる場合は、cmd から Web 構成暗号化ツールを使用できます。以下を含む web.config と同じフォルダーに .bat ファイルを作成します。

aspnet_regiis -pef connectionStrings .
aspnet_regiis -pef appSettings .
pause

これにより、connectionStrings セクション全体が暗号化され、私の場合は appSettings セクション全体も暗号化されます。

復号化するには、次のようにします。

aspnet_regiis -pdf connectionStrings .
aspnet_regiis -pdf appSettings .
pause

ただし、これをサーバーから実行する必要があります。

于 2012-09-04T10:28:43.103 に答える