您当前位置:网站首页 >> 编程开发 >> JavaScript >> 用JavaScript加密保护网站页面

用JavaScript加密保护网站页面

2013-10-16 20:09:44 来源:奇库斯(QCOOLS) 浏览:993
关键字:JavaScript,加密,保护,网站,页面

内容提要:

我们经常会遇到一些必须输入用户名和密码才能进入的网站。其实我们也可以对自己的网站页面进行简单的加密,具体操作请看下文:
第一步:创建密码登录页
将如下代码加入HTML的<BODY>区:
  <script LANGUAGE="JavaScript">
<!--
flag=0

  我们经常会遇到一些必须输入用户名和密码才能进入的网站。其实我们也可以对自己的网站页面进行简单的加密,具体操作请看下文:

  第一步:创建密码登录页

  将如下代码加入HTML的<BODY>区:

  <script LANGUAGE="JavaScript">
<!--
flag=0
flag2=0
-->
</script>
<script LANGUAGE="JavaScript" SRC="password.txt"> //密码表文件
</script>
<script LANGUAGE="JavaScript" SRC="password1.txt"> //密码验证文件
</script>
<h1 align="center">Login</h1>
<script LANGUAGE="JavaScript">
<!--
function main()
{
member = document.all.username.value
pass = document.all.password.value
encryption()
password()
}
-->
</script>
<p>输入用户名: <input TYPE="TEXT" ID="username" size="20"> <br>
请输入密码: <input TYPE="PASSWORD" ID="password" size="20">
<input TYPE="BUTTON" ID="button" onclick="main()" value="Enter!" align="center"> </p>


  第二步:分别编辑文件1(password.txt)和文件2(password1.txt),适合你自己的页面情况,主要是密码设定和用户名设定。
文件1:password.txt
一张密码表,一看就懂,没有什么难度。可以自由设计,注意大小写的区别。

function encryption()<BR>{<BR>mm = "Z"<BR>k = "j"<BR>b = "p"<BR>mmmm = "&"<BR>ccc = "6"<BR>l = "i"<BR>c = "q"<BR>m = "s"<BR>abcd = "m"<BR>o = "n"<BR>u = "z"<BR>e = "d"<BR>gg = "U"<BR>p = "u"<BR>jj = "O"<BR>v = "a"<BR>j = "y"<BR>x = "c"<BR>r = "n"<BR>bb = "D"<BR>cc = "K"<BR>z = "w"<BR>a = "x"<BR>ee = "G"<BR>n = "f"<BR>ff = "T"<BR>i = "g"<BR>w = "r"<BR>ii = "V"<BR>kk = "I"<BR>q = "o"<BR>oooo = ")"<BR>d = "e"<BR>nn = "E"<BR>oo = "P"<BR>pp = "X"<BR>t = "h"<BR>s = "v"<BR>rr = "S"<BR>ss = "L"<BR>tt = "R"<BR>uu = "A"<BR>h = "k"<BR>vv = "C"<BR>ww = "M"<BR>aa = "Y"<BR>xx = "Q"<BR>hh = "B"<BR>yy = "H"<BR>zz = "W"<BR>y = "t"<BR>qq = "J"<BR>aaa = "8"<BR>bbb = "0"<BR>f = "b"<BR>ddd = "9"<BR>eee = " "<BR>fff = "3"<BR>dd = "N"<BR>ggg = "4"<BR>hhh = "1"<BR>iii = "2"<BR>jjj = "7"<BR>kkk = "5"<BR>lll = "."<BR>mmm = ","<BR>nnn = ";"<BR>ooo = ":"<BR>ppp = "´"<BR>qqq = "<"<BR>rrr = ">"<BR>sss = "-"<BR>ttt = "_"<BR>uuu = "="<BR>vvv = "/"<BR>www = "?"<BR>xxx = "`"<BR>yyy = "~"<BR>zzz = "*"<BR>aaaa = "+"<BR>bbbb = "["<BR>cccc = "]"<BR>g = "l"<BR>dddd = "{"<BR>eeee = "}"<BR>ffff = ""<BR>gggg = "|"<BR>hhhh = "!"<BR>iiii = "@"<BR>jjjj = "#"<BR>kkkk = "code:quot;<BR>llll = "%"<BR>nnnn = "("<BR>}

文件2:password1.txt

function password()<BR>{<BR>if(member==i+p+d+m+y) //第一个用户名;对照密码表翻译为:guest<BR>{<BR>if(pass==hhh+iii+fff+ggg) //第一个密码;对照密码表翻译为:1234<BR>{<BR>alert("还在外面傻站着干吗 " + member + "...") //输入正确后的提示语<BR>window.location.href = x+q+e+d+lll+t+y+abcd //密码正确后进入的页面code.htm(对密码表)<BR>flag2=1<BR>}<BR>}<BR>if(member==k+v+j) //设定第二个用户名,以下类推...<BR>{<BR>if(pass==f+i+p+d)<BR>{<BR>alert("还在外面傻站着干吗 " + member + "...")<BR>window.location.href = s+b+v+x+x+lll+t+y+abcd<BR>flag2=1<BR>}<BR>}<BR>if(member==qqq+llll+ttt+llll+rrr) //设定第三个用户名,以下类推...<BR>{<BR>if(pass==ooo+sss+oooo)<BR>{<BR>alert("还在外面傻站着干吗 " + member + "...")<BR>window.location.href = s+b+v+x+x+lll+t+y+abcd<BR>flag2=1<BR>}<BR>}<BR>if(member=="")<BR>{<BR>}<BR>else<BR>{<BR>if(flag==3) //设定允许连续输错密码的次数<BR>{<BR>window.location.href = "http://cn.geocities.com/enetvhome" //连续3次输错后导向该页面<BR>flag2=1<BR>}<BR>if(flag2==1) <BR>else<BR>{<BR>alert ("对不起,今天我心情不好,在外面待会儿吧!") //输错密码后的警示语<BR>flag=flag+1<BR>}<BR>}<BR>}



相关文章
发表评论
网名:
评论:
验证:
共有0人对本文发表评论查看所有评论(仅供表达个人看法,并不表明本站同意其观点或证实其描述)
赞助商链接
点击排行