熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> JSP教程 >> 正文

用JavaScript為你的網站加密

2013-11-15 11:47:19  來源: JSP教程 
我們經常會遇到一些必須輸入用戶名和密碼才能進入的網站其實我們也可以對自己的網站頁面進行簡單的加密具體操作請看下文

  第一步創建密碼登錄頁
  將如下代碼加入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+
  }
  }
  }
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19629.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.