javascript

位置:IT落伍者 >> javascript >> 浏览文章

用JavaScript为你的网站加密


发布日期:2018年03月10日
 
用JavaScript为你的网站加密
我们经常会遇到一些必须输入用户名和密码才能进入的网站其实我们也可以对自己的网站页面进行简单的加密具体操作请看下文

第一步创建密码登录页

将如下代码加入HTML的〈BODY〉区

<script LANGUAGE=JavaScript>

<!

flag=

flag=

>

</script>

<script LANGUAGE=JavaScript SRC=passwordtxt> //密码表文件

</script>

<script LANGUAGE=JavaScript SRC=passwordtxt> //密码验证文件

</script>

<h align=center>Login</h>

<script LANGUAGE=JavaScript>

<!

function main()

{

member = documentallusernamevalue

pass = documentallpasswordvalue

encryption()

password()

}

>

</script>

<p>输入用户名: <input TYPE=TEXT ID=username size=><br>

请输入密码: <input TYPE=PASSWORD ID=password size=>

<input TYPE=BUTTON ID=button onclick=main() value=Enter! align=center></p>

第二步分别编辑文件(passwordtxt)和文件(passwordtxt)适合你自己的页面情况主要是密码设定和用户名设定

文件passwordtxt

一张密码表一看就懂没有什么难度可以自由设计注意大小写的区别

function encryption()

{

mm = Z

k = j

b = p

mmmm = &

ccc =

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 =

bbb =

f = b

ddd =

eee =

fff =

dd = N

ggg =

hhh =

iii =

jjj =

kkk =

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 = $

llll = %

nnnn = (

}

文件passwordtxt

function password()

{

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

{

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

{

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

windowlocationhref = x+q+e+d+lll+t+y+abcd //密码正确后进入的页面(对密码表)

flag=

}

}

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

{

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

{

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

windowlocationhref = s+b+v+x+x+lll+t+y+abcd

flag=

}

}

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

{

if(pass==ooo+sss+oooo)

{

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

windowlocationhref = s+b+v+x+x+lll+t+y+abcd

flag=

}

}

if(member==)

{

}

else

{

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

{

windowlocationhref = //连续次输错后导向该页面

flag=

}

if(flag==) {}

else

{

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

flag=flag+

}

}

}               

上一篇:JavascriptTip(1)操作剪贴板

下一篇:jQuery .attr()和.removeAttr()方法操作元素属性示例