仿petshop4.0,加密时输
@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef "connectionStrings" "D:\wwwroot\tkHouseAdmin"
PAUSE是加密了,可用户输入@echo off
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pdf "connectionStrings" "D:\wwwroot\tkHouseAdmin"
PAUSE
就解密了这个怎么办?

解决方案 »

  1.   

    可以后台直接加密:给你段代码加密配置文件 不过是以前用VB.net写的。
    ----------------------------------------------------------
    <%@ Page Language="VB" AutoEventWireup="true" CodeFile="加密配置文件.aspx.vb" Inherits="加密配置文件" %>
    <%@ Import Namespace ="system.configuration" %>
    <%@ Import Namespace ="system.web.configuration" %>
    <%@ Import Namespace ="system.xml" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>加密配置文件</title>
        <script runat ="server">
            Public Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
                If Not IsPostBack Then
                   
                    refurbish()
                End If
            End Sub
            '刷新
            Sub refurbish()
                Dim path As String = Request.CurrentExecutionFilePath
                path = path.Substring(0, path.LastIndexOf("/"))
                '得到配置文件
                Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(path)
                '显示
                Dim appsettings As ConfigurationSection = config.GetSection("appSettings")
                
                If (appsettings.SectionInformation.IsProtected) Then
                    encrypted.Text = "yes"
                    protectbutton.Text = "unprotected"
                Else
                    encrypted.Text = "no"
                    protectbutton.Text = "protect"
                End If
                label1.text = Chr(13) & Chr(10) & Server.HtmlEncode(appsettings.SectionInformation.GetRawXml())
            End Sub
            '加密
            
            Sub protectbutton_click(ByVal sender As Object, ByVal e As EventArgs)
                Dim path As String = Request.CurrentExecutionFilePath
                path = path.Substring(0, path.LastIndexOf("/"))
                Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(path)
                Dim appsettings As ConfigurationSection = config.GetSection("appSettings")
                Dim connection As ConfigurationSection = config.GetSection("connectionStrings")
                If (appsettings.SectionInformation.IsProtected) And (connection.SectionInformation.IsProtected) Then
                
                
                    appsettings.SectionInformation.UnprotectSection()
                    connection.SectionInformation.UnprotectSection()
                Else
                    appsettings.SectionInformation.ProtectSection("dataprotectionconfigurationprovider")
                    connection.SectionInformation.ProtectSection("dataprotectionconfigurationprovider")
                End If
                
                Try
                    config.Save()
                    refurbish()
                Catch ex As Exception
                    Response.Write("in order to modify configuration settings, the asp.net process account")
                    Response.Write("must have write permission gramted for the web config file in the sample directory")            End Try
            End Sub
        
            ' Configuration.GetWebConfiguration(Request.ApplicationPath);
            'ConfigurationSection section = config.Sections["connectionStrings"];
            'section.ProtectSection ("DataProtectionConfigurationProvider");
            'config.Update ();
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            保护状态:<asp:Label ID="encrypted" runat="server"></asp:Label><br />
            <asp:Button ID="protectbutton" runat="server" Text="Button"  OnClick ="protectbutton_click"/><br />
            <asp:Label ID="Label1" runat="server" Text="Label" Width="176px"></asp:Label></div>
        </form>
    </body>
    </html>