首先添加引用: using system.web.configuration;
加密操作如下:
以下为引用的内容: private void protectsection(string sectionname, string provider) configurationsection section = config.getsection(sectionname); if (section != null && !section.sectioninformation.isprotected) |
解密操作如下:
以下为引用的内容:
configurationsection section = config.getsection(sectionname); if (section != null && section.sectioninformation.isprotected) |
加密前的配置文件:
以下为引用的内容: <?xml version="1.0"?> <configuration> <appsettings> <add key="name" value="shy520" /> <add key="address" value="cnblogs" /> </appsettings> <system.web> <compilation debug="true"/> </system.web> </configuration> 加密后的配置文件: <?xml version="1.0"?> <configuration> <appsettings configprotectionprovider="dataprotectionconfigurationprovider"> <encrypteddata> <cipherdata> <ciphervalue> aqaaancmnd8bfderjhoawe/cl+s baaaabi1atlnkeugef0xywgl2xg qaaaacaaaaaaadzgaaqaaaabaaa abihxmwlazantwiipst1cdxaaaa aasaaacgaaaaeaaaapz/ykyx07c b+h4fqdr4fklgaaaax1ieyc+wsx afsdw1vn2c/fxsg2tanyeugacov 8e3ngfthhsh91gliqkregfpyzgr vw1xrez/3vwomji9es7efkrcxej nnhl66kg2inrk3ntlnzlztts3cz 9w63u47vkajs6miwsgbz2gntl/9 ughleligrjcr3yj+lsjoscexqnv hgva48efxpd+teifbtgxehsfkqx cqgysshx16vct2gunuc3zmeahbh usafkpiyqelyhd4+m9a/xpe2tqw gibla1wbw2ndefrzjpwnkfmpnqr hxijkimipwxbdvyy6o0uaaaas8d suynohj7qajja2c/4euc7sks= </ciphervalue> </cipherdata> </encrypteddata> </appsettings> <system.web> <compilation debug="true"/> </system.web> </configuration> |
新闻热点
疑难解答
图片精选