/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* See http://pajhome.org.uk/site/legal.html for details.
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
* 需要加密的文字或者数字作为必要参数传入: hexMD5.hexMD5(参数);
(Text or Numbers that need to be encrypted are passed in as necessary parameters: hexMD5.hexMD5(params))
* author: cxr
*//*
参考代码
*/functionsafe_add(x, y){
var lsw =(x &0xFFFF)+(y &0xFFFF)var msw =(x >>16)+(y >>16)+(lsw >>16)return(msw <<16)|(lsw &0xFFFF)}/*
* Bitwise rotate a 32-bit number to the left.
*/functionrol(num, cnt){
return(num << cnt)|(num >>>(32- cnt))}/*
* These functions implement the four basic operations the algorithm uses.
*/functioncmn(q, a, b, x, s, t){
returnsafe_add(rol(safe_add(safe_add(a, q),safe_add(x, t)), s), b)}functionff(a, b, c, d, x, s, t){
returncmn((b & c)|((~b)& d), a, b, x, s, t)}functiongg(a, b, c, d, x, s, t){
returncmn((b & d)|(c &(~d)), a, b, x, s, t)}functionhh(a, b, c, d, x, s, t){
returncmn(b ^ c ^ d, a, b, x, s, t)}functionii(a, b, c, d, x, s, t){
returncmn(c ^(b |(~d)), a, b, x, s, t)}/*
* Calculate the MD5 of an array of little-endian words, producing an array
* of little-endian words.
*/functioncoreMD5(x){
var a =1732584193var b =-271733879var c =-1732584194var d =271733878for(var i =0; i < x.length; i +=16){
var olda = a
var oldb = b
var oldc = c
var oldd = d
a =ff(a, b, c, d, x[i +0],7,-680876936)
d =ff(d, a, b, c, x[i +1],12,-389564586)
c =ff(c, d, a, b, x[i +2],17,606105819)
b =ff(b, c, d, a, x[i +3],22,-1044525330)
a =ff(a, b, c, d, x[i +4],7,-176418897)
d =ff(d, a, b,