人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

August 19, 2006

PetShop Connection string加解密

Filed under: 代码学习

EncryptWebConfig.bat
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef “connectionStrings” “C:\Program Files\Microsoft\.NET Pet Shop 4.0\Web”

DecryptWebConfig.bat
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf “connectionStrings” “C:\Program Files\Microsoft\.NET Pet Shop 4.0\Web”

另:可通过代码加解密的connection string
public void EncryptConfig(bool bEncrypt)
{
string path = “/tricks”;

Configuration config = WebConfigurationManager.OpWebConfiguration(path);
ConfigurationSection appSettings = config.GetSection(”connectionString”);

if(bEncrypt)
{
appSettings.SetionInformation.ProtectSection(”DataProtectionConfigurationProvider”);
}
else
{
appSettings.SetionInformation.UnprotectSection();
}
config.Save();
}

程序中使用connection string的部分勿需关心web.config是否加密,
public static readonly string ConnectionStringMembership = ConfigurationManager.ConnectionStrings[”myConnString”].ConnectionString;

Comments »

The URI to TrackBack this entry is: http://recordsome.blogsome.com/2006/08/19/p152/trackback/

No comments yet.

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham