javascript加密

用途,加密方法,第一步:創建密碼登錄頁,第二步,

用途

隨著網際網路的快速發展,網站客戶端(瀏覽器IE(ff)運行的javaSCRIPT代碼常常被別人輕易的拷貝, 為了保護程式設計師自己的勞動成果,因此程式設計師不得不對想辦法保護自己原始碼-------javascript加密

加密方法

第一步:創建密碼登錄頁

將如下代碼加入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”>
請輸入密碼: <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 = “網站地址” //連續3次輸錯後導向該頁面
flag2=1
}
if(flag2==1)
else
{
alert (“對不起,今天我心情不好,在外面待會兒吧!”) //輸錯密碼後的警示語
flag=flag+1
}
}
}

相關詞條

熱門詞條

聯絡我們