把明文的密碼寫在Web.Config裡面總是不太好吧!
加密一下,至少顯得專業點,下面是我的方法:
ASPnet_regIIS -pef "connectionStrings" "f:\DOTNETAPP2.0\SCHOOLP
ROFILE" -prov "DataProtectionConfigurationProvider"
注意:後面一定要"DataProtectionConfigurationProvider" ,不加這個參數,就是用默認方式加密。
處理起來很羅嗦!connectionStrings可以替換成你需要的加密配置節,另外
有的SECTION是不能加密的,要注意!
用"DataProtectionConfigurationProvider" 參數,加密後,可以不用解密處理,系統依舊能使用原來
的連接串正常連接數據庫!
加密前:
<connectionStrings>
<add name="MyConn" connectionString="server=localhost;uid=sa;pwd=123456;Initial Catalog=SchoolProfile"
providerName="System.Data.SqlClIEnt" />
</connectionStrings>
加密後:
<connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
<EncryptedData>
<CipherData>
<CipherValue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA5T1gcwVg/0qvVeziLTglSQQAAAACAAAAAAADZgAAqAAAABAAAADt4LPmdEtJP3O3F2k2tEUWAAAAAASAAACgAAAAEAAAACVZduywWhhWOVjg0aRY/RYAAgAANmIZ0DQGMCZL42BtSs7rmUZVc1DE0kOm8Yb+LkngV4qkd7DY5JOBz6mCMi8sMBOllQ9n8iNgfhk+0IYAvXRnGXO4RL13pcmNwzJHRqNSZMUX9a5qtVz+JSQFqJLM+9sM8lDyjA77H9p+Yi5pzQtdkDk5w5M2hTSOK/ku3SUCXE9UZgYQxYvvmhO3WXkLx69nMFRNxskVqznK3s0EzQDtqA4oJE8RL1lzKlqRqbUIEnMcwB4N7/mFqcNmm7zJPKDgawZszlaLITAgIivyyWHPtcz1flT1hZsgmFWqpucNSSz6lJCA2TM10Z2sQ44augCiZi0XJyTaRrhGw51v8bR9oZtqxDiLxn89c1VqSUnPeO51ukQPEO0nCR+wN414AiQMrg3mv8YZB05kawx9kt6K79j45sAxaumCkhUML9uU21NPJCPfzKukhab/rhqeBHQGiIvKfVCC3H8TB2XOR5a4lA1jLo7ceOtehjgVZqn5XKocLyzYbBkKzMZNnEcgcrsgdOmUgs3IajmtzZ1x2zcOqMdcoZJYNxCXGzCNMviIEV+C7/O6iqnYL3p0G4dKHhkcXoJm5pssNItS1OgsPCdtwBRfF6Fza7RimRW6iK/KIU/eih+OPc/2n0u2GsIgq5KjQuow3aTmy99dAC3kxTvxtbRFE8xbNPdBqYW6++vCm5sUAAAAY70pIKQBMd07W9P4heo6xJDfpIM=</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>