配置文件的使用,加密用法

来源:互联网 发布:考研英语作文模板知乎 编辑:程序博客网 时间:2024/06/07 01:27
<configuration>
  <!--设置目录或文件的权限-->
  <location path="admin">
    <system.web>
      <authorization>
        <deny users="?"/>
      </authorization>
      
    </system.web>
  </location>
  <location path="admin/images">


    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
    <system.web>
        <compilation debug="true" targetFramework="4.0" />
      <!--forms 身份验证
      原理是向客户端写cookie,
      然后在每个页面自动给我判断这个cookie是否存在
      以判断能不能进入这个页面!
      -->
      <!--授权-->
      <authorization>
        <!--<allow 允许/>-->
        <!--deny 阻止指定人访问   * 表示所有人   ?表示没有登录的人-->
        <!--<deny users="admin"/>--><!--就算admin登录成功也不让进-->
        <!--<deny users="?"/>-->
        <allow users="*"/>
      </authorization>
      <authentication mode="Forms">
        <!--LoginUrl 登录页面
        defaultUrl 登录成功后默认跳转的页面
        timeout 过期时间 20分钟
        name cookie的名称
        -->
        <forms defaultUrl="/admin/Index.aspx" loginUrl="/admin/Login.aspx" timeout="20" name="user">
         
        </forms>
      </authentication>
    </system.web>


  <appSettings>
    <add key="conStr" value="server=192.168.39.23;uid=sa;pwd=123;database=n1204"/>
    <add key="serverIp" value="192.168.39.23"/>
  </appSettings>
  <!--连接字符串-->
  <connectionStrings>
    <add name="conn" connectionString="server=192.168.39.23;uid=sa;pwd=123;database=n1204"/>
  </connectionStrings>
  

</configuration>



            //md5加密
            string s = TextBox1.Text;
          string str=  FormsAuthentication.HashPasswordForStoringInConfigFile(s,"MD5");
          string str1 = FormsAuthentication.HashPasswordForStoringInConfigFile(s, "SHA1");
          Label1.Text = "MD5:"+str+"/"+str.Length;
          Response.Write("SHA1:"+str1+"/"+str1.Length);

原创粉丝点击