用dhtml做了一个密码管理器[4]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 emu 的 blog

  pwd = prompt("password uncorrect , please enter your access password again","");

 if (pwd == null || md5(escape(generatekeybypwd(pwd)))!=key_md5) {
  if (confirm("do you want to get back your password?")){
   var a1 = prompt("please answer folowing question:"+question1,"");
   var a2 = prompt("please answer folowing question:"+question2,"");
   var a3 = prompt("please answer folowing question:"+question3,"");
   if (answermd5 != md5("answers:"+escape(a1+a2+a3))){
    alert("uncorrect answers. sorry, you cannot access this password file.");
    return;
   }else{
    key =  reminder.xor(generatekeybypwd("answer1:"+a1)).xor(generatekeybypwd("answer2:"+a2)).xor(generatekeybypwd("answer3:"+a3));
   }
  }else{
   return;
  }
 }else{
  key = generatekeybypwd(pwd);
 }

 if (data != ""){
  if (md5(data)==data_md5){
   try{
    execscript(unescape(data).xor());
   }catch(e){
    alert("data error! password file maybe destoried!");
   }
  }else{
   alert("password file maybe destoried!");
  }
 }

 showpwds();

 var btns = document.getelementsbytagname("button");
 for(var i=0;i<btns.length;i++)btns[i].disabled=false;
}

function showpwds(){
 var table = ["<table align=center width=700 bgcolor=black cellspacing=1 style=font-size:15><tr bgcolor=#ccccff><th>title</th><th>password</th><th>&nbsp;</th></tr><tbody bgcolor=#ffffcc align=center>"];
 for (var i in pwds)
  if (pwds[i]){
   table[table.length] = "<tr><td ondblclick='modifytitle(this)'>"
   table[table.length] = unescape(i).xor()
   table[table.length] = "</td><td ondblclick='modifypwd(this)'>"
   table[table.length] = unescape(pwds[i]).xor();
   table[table.length] = "</td><td><button onclick=removepwd('";
   table[table.length] = i;
   table[table.length] = "')><font color=red>delete</font></button> &nbsp; <button onclick=clipboarddata.setdata('text','";
   table[table.length] = unescape(pwds[i]).xor();
   table[table.length] = "');><font color=green>copy</font></button></td></tr>";
  }
 table[table.length] = "</tbody></table>"
 content.innerhtml = table.join("");
}

function addpwd(){
 var title = prompt("please enter new password title","");
 if (!title) return;
 if (pwds[escape(title.xor())]!= null)
 if (!confirm("title already exist. do you really want to over write it? ")) return;
 var newpwd = prompt("please enter new password","");
 pwds[escape(title.xor())] = escape(newpwd.xor());
 storepwds();
 showpwds();
}

function storepwds(){
 var st = [];
 for (var i in pwds)
  if (pwds[i])
   st[st.length] = 'pwds["'+i+'"]="'+pwds[i]+'";';
 st = st.join("");
 st = escape(st.xor());
 var s = fso.opentextfile("passwordfile.js",2,true);
 s.write("data=\""+st+"\";");
 s.write("data_md5=\""+md5(st)+"\";");
 s.write('key_md5 = "'+md5(escape(key))+'";');
 s.write('answermd5 = "'+answermd5+'";');
 s.write('reminder = unescape("'+escape(reminder)+'");');
 s.write('question1 = unescape("'+escape(question1)+'");');
 s.write('question2 = unescape("'+escape(question2)+'");');
 s.write('question3 = unescape("'+escape(question3)+'");');
 s.close();
}


function changeaccesspwd(){
 var newpwd = prompt("please enter new access password","");
 if (!newpwd || newpwd=="") return;
 var newkey = generatekeybypwd(newpwd);

 var newpwds = new object();
 for (var i in pwds)
 if (pwds[i])
 newpwds[escape(unescape(i).xor().xor(newkey))] = escape(unescape(pwds[i]).xor().xor(newkey));
 reminder=reminder.xor().xor(newkey);
 key = newkey;
 pwds = newpwds;
 storepwds();
}

function changeaccesspwdremander(){
 var q1,q2,q3,a1,a2,a3;
 if ((q1 = prompt("please enter first new question:",question1))!=null
  && (a1 = prompt("please enter answer of first question:",""))!=null

本文关键:emu 加密 解密
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top