javascript客户端⽣成MD5值的函数代码测试代码:
language="javascript"> /*javascript的特性
全选注:引⼊外部Js需再刷新⼀下页⾯才能执⾏]
RSA Data Security, Inc.
MD5 Message * Digest
Algorithm, as defined in
RFC 1321. * Copyright
(C) Paul Johnston 1999 -
2000. * Updated by Greg
Holt 2000 - 2001. * See
uk/site
/
legal.html for details. */
var hex_chr =
"0123456789abcdef";
function rhex(num) { str =
""; for(j = 0; j <= 3; j++) str
+= hex_chr.charAt((num
>> (j * 8 + 4)) & 0x0F) +
hex_chr.charAt((num >>
(j * 8)) & 0x0F); return str;
} function
str2blks_MD5(str) { nblk
= ((str.length + 8) >> 6) +
1; blks = new Array(nblk *
16); for(i = 0; i < nblk * 16;
i++) blks[i] = 0; for(i = 0; i
< str.length; i++) blks[i >>
2] |= str.charCodeAt(i) <<
((i % 4) * 8); blks[i >> 2] |=
0x80 << ((i % 4) * 8);
blks[nblk * 16 - 2] =
str.length * 8; return blks;
} function add(x, y) { var
lsw = (x & 0xFFFF) + (y &
0xFFFF); var msw = (x
>> 16) + (y >> 16) + (lsw
>> 16); return (msw <<
16) | (lsw & 0xFFFF); }
function rol(num, cnt) {
return (num << cnt) |
(num >>> (32 - cnt)); }
function cmn(q, a, b, x, s,
t) { return
add(rol(add(add(a, q),
add(x, t)), s), b); } function
ff(a, b, c, d, x, s, t) { return
cmn((b & c) | ((~b) & d), a,
b, x, s, t); } function gg(a,
b, c, d, x, s, t) { return
cmn((b & d) | (c & (~d)), a,
b, x, s, t); } function hh(a,
b, c, d, x, s, t) { return
cmn(b ^ c ^ d, a, b, x, s, t);
} function ii(a, b, c, d, x, s,
t) { return cmn(c ^ (b |
(~d)), a, b, x, s, t); }
function MD5(str) { x =

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。