用JavaScript為你的網站加密

來源:互聯網
上載者:User
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"><br>
  請輸入密碼: <input TYPE="PASSWORD" ID="password" size="20">
  <input TYPE="BUTTON" ID="button" 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 = "$"
  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
  }
  }
  }

相關文章

Beyond APAC's No.1 Cloud

19.6% IaaS Market Share in Asia Pacific - Gartner IT Service report, 2018

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。