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

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

本文简介:选择自 emu 的 blog

 b = ii ( b, c, d, a, x[13], s44, 0x4e0811a1); /* 60 */
 a = ii ( a, b, c, d, x[ 4], s41, 0xf7537e82); /* 61 */
 d = ii ( d, a, b, c, x[11], s42, 0xbd3af235); /* 62 */
 c = ii ( c, d, a, b, x[ 2], s43, 0x2ad7d2bb); /* 63 */
 b = ii ( b, c, d, a, x[ 9], s44, 0xeb86d391); /* 64 */

 state[0] +=a;
 state[1] +=b;
 state[2] +=c;
 state[3] +=d;

    }


    function init() {
 count[0]=count[1] = 0;
 state[0] = 0x67452301;
 state[1] = 0xefcdab89;
 state[2] = 0x98badcfe;
 state[3] = 0x10325476;
 for (i = 0; i < digestbits.length; i++)
     digestbits[i] = 0;
    }

    function update(b) {
 var index,i;
 
 index = and(shr(count[0],3) , 0x3f);
 if (count[0]<0xffffffff-7)
   count[0] += 8;
        else {
   count[1]++;
   count[0]-=0xffffffff+1;
          count[0]+=8;
        }
 buffer[index] = and(b,0xff);
 if (index  >= 63) {
     transform(buffer, 0);
 }
    }

    function finish() {
 var bits = new array(8);
 var padding;
 var i=0, index=0, padlen=0;

 for (i = 0; i < 4; i++) {
     bits[i] = and(shr(count[0],(i * 8)), 0xff);
 }
        for (i = 0; i < 4; i++) {
     bits[i+4]=and(shr(count[1],(i * 8)), 0xff);
 }
 index = and(shr(count[0], 3) ,0x3f);
 padlen = (index < 56) ? (56 - index) : (120 - index);
 padding = new array(64);
 padding[0] = 0x80;
        for (i=0;i<padlen;i++)
   update(padding[i]);
        for (i=0;i<8;i++)
   update(bits[i]);

 for (i = 0; i < 4; i++) {
     for (j = 0; j < 4; j++) {
  digestbits[i*4+j] = and(shr(state[i], (j * 8)) , 0xff);
     }
 }
    }

/* end of the md5 algorithm */

function hexa(n) {
 var hexa_h = "0123456789abcdef";
 var hexa_c="";
 var hexa_m=n;
 for (hexa_i=0;hexa_i<8;hexa_i++) {
   hexa_c=hexa_h.charat(math.abs(hexa_m)%16)+hexa_c;
   hexa_m=math.floor(hexa_m/16);
 }
 return hexa_c;
}


var ascii="01234567890123456789012345678901" +
          " !\"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz"+
          "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";

function md5(entree)
{
 var l,s,k,ka,kb,kc,kd;

 init();
 for (k=0;k<entree.length;k++) {
   l=entree.charat(k);
   update(ascii.lastindexof(l));
 }
 finish();
 ka=kb=kc=kd=0;
 for (i=0;i<4;i++) ka+=shl(digestbits[15-i], (i*8));
 for (i=4;i<8;i++) kb+=shl(digestbits[15-i], ((i-4)*8));
 for (i=8;i<12;i++) kc+=shl(digestbits[15-i], ((i-8)*8));
 for (i=12;i<16;i++) kd+=shl(digestbits[15-i], ((i-12)*8));
 s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka);
 return s;
}

/*--------------------------------- end of md5 function ----------------------------------*/

/*------------------------------- encrypt/decrypt function -------------------------------*/
string.prototype.xor = function (key){
 if (key==null) key=window.key;
for (var i=0,result="";i<this.length;i++)
 result += string.fromcharcode(this.charcodeat(i)^key.charcodeat(i%key.length));
return result;
}
/*--------------------------- end of encrypt/decrypt function ----------------------------*/


var pwd=0,key=0,pwds = new object(),fso = new activexobject("scripting.filesystemobject"),data="",data_md5="",question1="",question2="",question3="";
var key_md5 = "de1b3bc4b324d43d8f730c7ce5884bf2",answermd5="ba7cbf39b32eab9f5584e59952e16e3d",reminder = unescape("%u39df%ua7bf%uf672%u87ee%ubab4%u7920%uc826%u7432%u86ca%uec92%u5791%u9637%uab38%ua295%ufa63%u0593%u8d3a%u33a2%u445d%ub6a8%u101b%u4514%ubf19%u651b%u779c%u66df%u475b%u1923%u33ac%uf171%udb1f%u22c5");

 

window.onload=function(){
 pwd = prompt("please enter your access password","");var i=0;
 while (pwd != null && md5(escape(generatekeybypwd(pwd)))!=key_md5 &&  i++<3)

本文关键:emu 加密 解密
 

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

go top