mirror of https://github.com/emn178/js-md4.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
4.4 KiB
JavaScript
10 lines
4.4 KiB
JavaScript
/*
|
|
* js-md4 v0.2.0
|
|
* https://github.com/emn178/js-md4
|
|
*
|
|
* Copyright 2015, emn178@gmail.com
|
|
*
|
|
* @license under the MIT license:
|
|
* http://www.opensource.org/licenses/MIT
|
|
*/
|
|
!function(e){"use strict";var r="object"==typeof process&&process.versions&&process.versions.node;r&&(e=global);var o,t=!e.JS_MD4_TEST&&"object"==typeof module&&module.exports,f="function"==typeof define&&define.amd,n=!e.JS_MD4_TEST&&"undefined"!=typeof ArrayBuffer,i="0123456789abcdef".split(""),s=[128,32768,8388608,-2147483648],a=[0,8,16,24],c=[];if(n){var d=new ArrayBuffer(68);o=new Uint8Array(d),c=new Uint32Array(d)}var u=function(e){var r="string"!=typeof e;r&&e.constructor==ArrayBuffer&&(e=new Uint8Array(e));var t,f,d,u,l,p,y,A,v,h,m,w,b,C,S=!0,T=!1,_=0,g=0,B=0,U=e.length||0;c[16]=0;do{if(c[0]=c[16],c[16]=c[1]=c[2]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0,r)if(n)for(C=g;U>_&&64>C;++_)o[C++]=e[_];else for(C=g;U>_&&64>C;++_)c[C>>2]|=e[_]<<a[3&C++];else if(n)for(C=g;U>_&&64>C;++_)b=e.charCodeAt(_),128>b?o[C++]=b:2048>b?(o[C++]=192|b>>6,o[C++]=128|63&b):55296>b||b>=57344?(o[C++]=224|b>>12,o[C++]=128|b>>6&63,o[C++]=128|63&b):(b=65536+((1023&b)<<10|1023&e.charCodeAt(++_)),o[C++]=240|b>>18,o[C++]=128|b>>12&63,o[C++]=128|b>>6&63,o[C++]=128|63&b);else for(C=g;U>_&&64>C;++_)b=e.charCodeAt(_),128>b?c[C>>2]|=b<<a[3&C++]:2048>b?(c[C>>2]|=(192|b>>6)<<a[3&C++],c[C>>2]|=(128|63&b)<<a[3&C++]):55296>b||b>=57344?(c[C>>2]|=(224|b>>12)<<a[3&C++],c[C>>2]|=(128|b>>6&63)<<a[3&C++],c[C>>2]|=(128|63&b)<<a[3&C++]):(b=65536+((1023&b)<<10|1023&e.charCodeAt(++_)),c[C>>2]|=(240|b>>18)<<a[3&C++],c[C>>2]|=(128|b>>12&63)<<a[3&C++],c[C>>2]|=(128|b>>6&63)<<a[3&C++],c[C>>2]|=(128|63&b)<<a[3&C++]);B+=C-g,g=C-64,_==U&&(c[C>>2]|=s[3&C],++_),_>U&&56>C&&(c[14]=B<<3,T=!0),S?(l=c[0]-1,l=l<<3|l>>>29,A=(4023233417&l|2562383102&~l)+c[1]+271733878,A=A<<7|A>>>25,y=(A&l|4023233417&~A)+c[2]-1732584194,y=y<<11|y>>>21,p=(y&A|~y&l)+c[3]-271733879,p=p<<19|p>>>13):(l=t,p=f,y=d,A=u,l+=(p&y|~p&A)+c[0],l=l<<3|l>>>29,A+=(l&p|~l&y)+c[1],A=A<<7|A>>>25,y+=(A&l|~A&p)+c[2],y=y<<11|y>>>21,p+=(y&A|~y&l)+c[3],p=p<<19|p>>>13),l+=(p&y|~p&A)+c[4],l=l<<3|l>>>29,A+=(l&p|~l&y)+c[5],A=A<<7|A>>>25,y+=(A&l|~A&p)+c[6],y=y<<11|y>>>21,p+=(y&A|~y&l)+c[7],p=p<<19|p>>>13,l+=(p&y|~p&A)+c[8],l=l<<3|l>>>29,A+=(l&p|~l&y)+c[9],A=A<<7|A>>>25,y+=(A&l|~A&p)+c[10],y=y<<11|y>>>21,p+=(y&A|~y&l)+c[11],p=p<<19|p>>>13,l+=(p&y|~p&A)+c[12],l=l<<3|l>>>29,A+=(l&p|~l&y)+c[13],A=A<<7|A>>>25,y+=(A&l|~A&p)+c[14],y=y<<11|y>>>21,p+=(y&A|~y&l)+c[15],p=p<<19|p>>>13,h=p&y,l+=(h|p&A|y&A)+c[0]+1518500249,l=l<<3|l>>>29,v=l&p,A+=(v|l&y|h)+c[4]+1518500249,A=A<<5|A>>>27,w=A&l,y+=(w|A&p|v)+c[8]+1518500249,y=y<<9|y>>>23,m=y&A,p+=(m|y&l|w)+c[12]+1518500249,p=p<<13|p>>>19,h=p&y,l+=(h|p&A|m)+c[1]+1518500249,l=l<<3|l>>>29,v=l&p,A+=(v|l&y|h)+c[5]+1518500249,A=A<<5|A>>>27,w=A&l,y+=(w|A&p|v)+c[9]+1518500249,y=y<<9|y>>>23,m=y&A,p+=(m|y&l|w)+c[13]+1518500249,p=p<<13|p>>>19,h=p&y,l+=(h|p&A|m)+c[2]+1518500249,l=l<<3|l>>>29,v=l&p,A+=(v|l&y|h)+c[6]+1518500249,A=A<<5|A>>>27,w=A&l,y+=(w|A&p|v)+c[10]+1518500249,y=y<<9|y>>>23,m=y&A,p+=(m|y&l|w)+c[14]+1518500249,p=p<<13|p>>>19,h=p&y,l+=(h|p&A|m)+c[3]+1518500249,l=l<<3|l>>>29,v=l&p,A+=(v|l&y|h)+c[7]+1518500249,A=A<<5|A>>>27,w=A&l,y+=(w|A&p|v)+c[11]+1518500249,y=y<<9|y>>>23,p+=(y&A|y&l|w)+c[15]+1518500249,p=p<<13|p>>>19,h=p^y,l+=(h^A)+c[0]+1859775393,l=l<<3|l>>>29,A+=(h^l)+c[8]+1859775393,A=A<<9|A>>>23,w=A^l,y+=(w^p)+c[4]+1859775393,y=y<<11|y>>>21,p+=(w^y)+c[12]+1859775393,p=p<<15|p>>>17,h=p^y,l+=(h^A)+c[2]+1859775393,l=l<<3|l>>>29,A+=(h^l)+c[10]+1859775393,A=A<<9|A>>>23,w=A^l,y+=(w^p)+c[6]+1859775393,y=y<<11|y>>>21,p+=(w^y)+c[14]+1859775393,p=p<<15|p>>>17,h=p^y,l+=(h^A)+c[1]+1859775393,l=l<<3|l>>>29,A+=(h^l)+c[9]+1859775393,A=A<<9|A>>>23,w=A^l,y+=(w^p)+c[5]+1859775393,y=y<<11|y>>>21,p+=(w^y)+c[13]+1859775393,p=p<<15|p>>>17,h=p^y,l+=(h^A)+c[3]+1859775393,l=l<<3|l>>>29,A+=(h^l)+c[11]+1859775393,A=A<<9|A>>>23,w=A^l,y+=(w^p)+c[7]+1859775393,y=y<<11|y>>>21,p+=(w^y)+c[15]+1859775393,p=p<<15|p>>>17,S?(t=l+1732584193<<0,f=p-271733879<<0,d=y-1732584194<<0,u=A+271733878<<0,S=!1):(t=t+l<<0,f=f+p<<0,d=d+y<<0,u=u+A<<0)}while(!T);return i[t>>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15]+i[f>>4&15]+i[15&f]+i[f>>12&15]+i[f>>8&15]+i[f>>20&15]+i[f>>16&15]+i[f>>28&15]+i[f>>24&15]+i[d>>4&15]+i[15&d]+i[d>>12&15]+i[d>>8&15]+i[d>>20&15]+i[d>>16&15]+i[d>>28&15]+i[d>>24&15]+i[u>>4&15]+i[15&u]+i[u>>12&15]+i[u>>8&15]+i[u>>20&15]+i[u>>16&15]+i[u>>28&15]+i[u>>24&15]};t?module.exports=u:(e.md4=u,f&&define(function(){return u}))}(this); |