<HTML>
<HEAD>
<META http-equiv=
'Content-Type'
content=
'text/html; charset=gb'
>
<TITLE>非常流行的JS的md加密办法</TITLE>
</HEAD>
<BODY >
<input id=test value=webasp>
<input type=button value=md onclick=
"alert(hex_md(test.value))"
>
<script>
var
hexcase = ;
var
bpad =
""
;
var
chrsz = ;
function
hex_md(s){
return
binlhex(core_md(strbinl(s), s.length * chrsz));}
function
b_md(s){
return
binlb(core_md(strbinl(s), s.length * chrsz));}
function
hex_hmac_md(key, data) {
return
binlhex(core_hmac_md(key, data)); }
function
b_hmac_md(key, data) {
return
binlb(core_hmac_md(key, data)); }
function
calcMD(s){
return
binlhex(core_md(strbinl(s), s.length * chrsz));}
function
md_vm_test()
{
return
hex_md(
"abc"
) ==
"cdfbdfdef"
;
}
function
core_md(x, len)
{
x[len >> ] |= x << ((len) % );
x[(((len + ) >>> ) << ) + ] = len;
var
a = ;
var
b = -;
var
c = -;
var
d = ;
for
(
var
i = ; i < x.length; i += )
{
var
olda = a;
var
oldb = b;
var
oldc = c;
var
oldd = d;
a = md_ff(a, b, c, d, x[i+ ], , -);
d = md_ff(d, a, b, c, x[i+ ], , -);
c = md_ff(c, d, a, b, x[i+ ], , );
b = md_ff(b, c, d, a, x[i+ ], , -);
a = md_ff(a, b, c, d, x[i+ ], , -);
d = md_ff(d, a, b, c, x[i+ ], , );
c = md_ff(c, d, a, b, x[i+ ], , -);
b = md_ff(b, c, d, a, x[i+ ], , -);
a = md_ff(a, b, c, d, x[i+ ], , );
d = md_ff(d, a, b, c, x[i+ ], , -);
c = md_ff(c, d, a, b, x[i+], , -);
b = md_ff(b, c, d, a, x[i+], , -);
a = md_ff(a, b, c, d, x[i+], , );
d = md_ff(d, a, b, c, x[i+], , -);
c = md_ff(c, d, a, b, x[i+], , -);
b = md_ff(b, c, d, a, x[i+], , );
a = md_gg(a, b, c, d, x[i+ ], , -);
d = md_gg(d, a, b, c, x[i+ ], , -);
c = md_gg(c, d, a, b, x[i+], , );
b = md_gg(b, c, d, a, x[i+ ], , -);
a = md_gg(a, b, c, d, x[i+ ], , -);
d = md_gg(d, a, b, c, x[i+], , );
c = md_gg(c, d, a, b, x[i+], , -);
b = md_gg(b, c, d, a, x[i+ ], , -);
a = md_gg(a, b, c, d, x[i+ ], , );
d = md_gg(d, a, b, c, x[i+], , -);
c = md_gg(c, d, a, b, x[i+ ], , -);
b = md_gg(b, c, d, a, x[i+ ], , );
a = md_gg(a, b, c, d, x[i+], , -);
d = md_gg(d, a, b, c, x[i+ ], , -);
c = md_gg(c, d, a, b, x[i+ ], , );
b = md_gg(b, c, d, a, x[i+], , -);
a = md_hh(a, b, c, d, x[i+ ], , -);
d = md_hh(d, a, b, c, x[i+ ], , -);
c = md_hh(c, d, a, b, x[i+], , );
b = md_hh(b, c, d, a, x[i+], , -);
a = md_hh(a, b, c, d, x[i+ ], , -);
d = md_hh(d, a, b, c, x[i+ ], , );
c = md_hh(c, d, a, b, x[i+ ], , -);
b = md_hh(b, c, d, a, x[i+], , -);
a = md_hh(a, b, c, d, x[i+], , );
d = md_hh(d, a, b, c, x[i+ ], , -);
c = md_hh(c, d, a, b, x[i+ ], , -);
b = md_hh(b, c, d, a, x[i+ ], , );
a = md_hh(a, b, c, d, x[i+ ], , -);
d = md_hh(d, a, b, c, x[i+], , -);
c = md_hh(c, d, a, b, x[i+], , );
b = md_hh(b, c, d, a, x[i+ ], , -);
a = md_ii(a, b, c, d, x[i+ ], , -);
d = md_ii(d, a, b, c, x[i+ ], , );
c = md_ii(c, d, a, b, x[i+], , -);
b = md_ii(b, c, d, a, x[i+ ], , -);
a = md_ii(a, b, c, d, x[i+], , );
d = md_ii(d, a, b, c, x[i+ ], , -);
c = md_ii(c, d, a, b, x[i+], , -);
b = md_ii(b, c, d, a, x[i+ ], , -);
a = md_ii(a, b, c, d, x[i+ ], , );
d = md_ii(d, a, b, c, x[i+], , -);
c = md_ii(c, d, a, b, x[i+ ], , -);
b = md_ii(b, c, d, a, x[i+], , );
a = md_ii(a, b, c, d, x[i+ ], , -);
d = md_ii(d, a, b, c, x[i+], , -);
c = md_ii(c, d, a, b, x[i+ ], , );
b = md_ii(b, c, d, a, x[i+ ], , -);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return
Array(a, b, c, d);
}
function
md_cmn(q, a, b, x, s, t)
{
return
safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function
md_ff(a, b, c, d, x, s, t)
{
return
md_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function
md_gg(a, b, c, d, x, s, t)
{
return
md_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function
md_hh(a, b, c, d, x, s, t)
{
return
md_cmn(b ^ c ^ d, a, b, x, s, t);
}
function
md_ii(a, b, c, d, x, s, t)
{
return
md_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
function
core_hmac_md(key, data)
{
var
bkey = strbinl(key);
if
(bkey.length > ) bkey = core_md(bkey, key.length * chrsz);
var
ipad = Array(), opad = Array();
for
(
var
i = ; i < ; i++)
{
ipad[i] = bkey[i] ^ x;
opad[i] = bkey[i] ^ xCCCC;
}
var
hash = core_md(ipad.concat(strbinl(data)), + data.length * chrsz);
return
core_md(opad.concat(hash), + );
}
function
safe_add(x, y)
{
var
lsw = (x & xFFFF) + (y & xFFFF);
var
msw = (x >> ) + (y >> ) + (lsw >> );
return
(msw << ) | (lsw & xFFFF);
}
function
bit_rol(num, cnt)
{
return
(num << cnt) | (num >>> ( - cnt));
}
function
strbinl(str)
{
var
bin = Array();
var
mask = ( << chrsz) - ;
for
(
var
i = ; i < str.length * chrsz; i += chrsz)
bin[i>>] |= (str.charCodeAt(i / chrsz) & mask) << (i%);
return
bin;
}
function
binlhex(binarray)
{
var
hex_tab = hexcase &
#63; "ABCDEF" : "abcdef";
var
str =
""
;
for
(
var
i = ; i < binarray.length * ; i++)
{
str += hex_tab.charAt((binarray[i>>] >> ((i%)*+)) & xF) +
hex_tab.charAt((binarray[i>>] >> ((i%)* )) & xF);
}
return
str;
}
function
binlb(binarray)
{
var
tab =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"
;
var
str =
""
;
for
(
var
i = ; i < binarray.length * ; i += )
{
var
triplet = (((binarray[i >> ] >> * ( i %)) & xFF) << )
| (((binarray[i+ >> ] >> * ((i+)%)) & xFF) << )
| ((binarray[i+ >> ] >> * ((i+)%)) & xFF);
for
(
var
j = ; j < ; j++)
{
if
(i * + j * > binarray.length * ) str += bpad;
else
str += tab.charAt((triplet >> *(-j)) & xF);
}
}
return
str;
}
</script>
</BODY></HTML>