会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > Web开发 > 脚本语言
用JavaScript加密保护网站页面
发表日期:2004-05-09 00:00:00作者: 出处:  

  文/周庆

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

  第一步:创建密码登录页

  将如下代码加入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()

{

mm = "Z"

k = "j"

b = "p"

mmmm = "&"

ccc = "6"

l = "i"

c = "q"

m = "s"

abcd = "m"

o = "n"

u = "z"

e = "d"

gg = "U"

p = "u"

jj = "O"

v = "a"

j = "y"

x = "c"

r = "n"

bb = "D"

cc = "K"

z = "w"

a = "x"

ee = "G"

n = "f"

ff = "T"

i = "g"

w = "r"

ii = "V"

kk = "I"

q = "o"

oooo = ")"

d = "e"

nn = "E"

oo = "P"

pp = "X"

t = "h"

s = "v"

rr = "S"

ss = "L"

tt = "R"

uu = "A"

h = "k"

vv = "C"

ww = "M"

aa = "Y"

xx = "Q"

hh = "B"

yy = "H"

zz = "W"

y = "t"

qq = "J"

aaa = "8"

bbb = "0"

f = "b"

ddd = "9"

eee = " "

fff = "3"

dd = "N"

ggg = "4"

hhh = "1"

iii = "2"

jjj = "7"

kkk = "5"

lll = "."

mmm = ","

nnn = ";"

ooo = ":"

ppp = "'"

qqq = "<"

rrr = ">"

sss = "-"

ttt = "_"

uuu = "="

vvv = "/"

www = "?"

xxx = "`"

yyy = "~"

zzz = "*"

aaaa = "+"

bbbb = "["

cccc = "]"

g = "l"

dddd = "{"

eeee = "}"

ffff = ""

gggg = "|"

hhhh = "!"

iiii = "@"

jjjj = "#"

kkkk = "code:quot;

llll = "%"

nnnn = "("

}

  文件2:password1.txt

  function password()

{

if(member==i+p+d+m+y) //第一个用户名;对照密码表翻译为:guest

{

if(pass==hhh+iii+fff+ggg) //第一个密码;对照密码表翻译为:1234

{

alert("还在外面傻站着干吗 " + member + "...") //输入正确后的提示语

window.location.href = x+q+e+d+lll+t+y+abcd //密码正确后进入的页面code.htm(对密码表)

flag2=1

}

}

if(member==k+v+j) //设定第二个用户名,以下类推...

{

if(pass==f+i+p+d)

{

alert("还在外面傻站着干吗 " + member + "...")

window.location.href = s+b+v+x+x+lll+t+y+abcd

flag2=1

}

}

if(member==qqq+llll+ttt+llll+rrr) //设定第三个用户名,以下类推...

{

if(pass==ooo+sss+oooo)

{

alert("还在外面傻站着干吗 " + member + "...")

window.location.href = s+b+v+x+x+lll+t+y+abcd

flag2=1

}

}

if(member=="")

{

}

else

{

if(flag==3) //设定允许连续输错密码的次数

{

window.location.href = "http://cn.geocities.com/enetvhome" //连续3次输错后导向该页面

flag2=1

}

if(flag2==1)

else

{

alert ("对不起,今天我心情不好,在外面待会儿吧!") //输错密码后的警示语

flag=flag+1

}

}

}

  

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00166