/**** md5 (message-digest algorithm)* http://www.webtoolkit.info/***/var md5 = function (string) { function rotateleft(lvalue, ishiftbits) { return (lvalue>(32-ishiftbits)); } function addunsigned(lx,ly) { var lx4,ly4,lx8,ly8,lresult; lx8 = (lx & 0x80000000); ly8 = (ly & 0x80000000); lx4 = (lx & 0x40000000); ly4 = (ly & 0x40000000); lresult = (lx & 0x3fffffff)+(ly & 0x3fffffff); if (lx4 & ly4) { return (lresult ^ 0x80000000 ^ lx8 ^ ly8); } if (lx4 | ly4) { if (lresult & 0x40000000) { return (lresult ^ 0xc0000000 ^ lx8 ^ ly8); } else { return (lresult ^ 0x40000000 ^ lx8 ^ ly8); } } else { return (lresult ^ lx8 ^ ly8); } } function f(x,y,z) { return (x & y) | ((~x) & z); } function g(x,y,z) { return (x & z) | (y & (~z)); } function h(x,y,z) { return (x ^ y ^ z); } function i(x,y,z) { return (y ^ (x | (~z))); } function ff(a,b,c,d,x,s,ac) { a = addunsigned(a, addunsigned(addunsigned(f(b, c, d), x), ac)); return addunsigned(rotateleft(a, s), b); }; function gg(a,b,c,d,x,s,ac) { a = addunsigned(a, addunsigned(addunsigned(g(b, c, d), x), ac)); return addunsigned(rotateleft(a, s), b); }; function hh(a,b,c,d,x,s,ac) { a = addunsigned(a, addunsigned(addunsigned(h(b, c, d), x), ac)); return addunsigned(rotateleft(a, s), b); }; function ii(a,b,c,d,x,s,ac) { a = addunsigned(a, addunsigned(addunsigned(i(b, c, d), x), ac)); return addunsigned(rotateleft(a, s), b); }; function converttowordarray(string) { var lwordcount; var lmessagelength = string.length; var lnumberofwords_temp1=lmessagelength + 8; var lnumberofwords_temp2=(lnumberofwords_temp1-(lnumberofwords_temp1 % 64))/64; var lnumberofwords = (lnumberofwords_temp2+1)*16; var lwordarray=array(lnumberofwords-1); var lbyteposition = 0; var lbytecount = 0; while ( lbytecount < lmessagelength ) { lwordcount = (lbytecount-(lbytecount % 4))/4; lbyteposition = (lbytecount % 4)*8; lwordarray[lwordcount] = (lwordarray[lwordcount] | (string.charcodeat(lbytecount)<
希望本文所述对大家javascript程序设计有所帮助。