Bitnot[w_]:=FromDigits[1-IntegerDigits[w,2,32],2]

Bitrotate[w_,n_]:=FromDigits[RotateLeft[IntegerDigits[w,2,32],n],2]

EndianSwap[x_]:=FromDigits[Reverse[IntegerDigits[x,256]],256]

Pad[x_]:=
Block[{bits=Flatten[IntegerDigits[x,2,8]]},
Block[{len=Length[bits]},
AppendTo[bits,1];
AppendTo[bits,ConstantArray[0,Mod[448-(len+1),512]]];
AppendTo[bits,Flatten[Map[Reverse[Partition[#,8]]&,Reverse[Partition[IntegerDigits[len,2,64],32]]]]];
Map[FromDigits[#,2]&,Partition[Flatten[bits],8]]
]
]

input=ToCharacterCode["The quick brown fox jumps over the lazy dog"];

input//Map[{FromCharacterCode[#],#}&,#]&//Partition[#,8,8,{1,1},{}]&//TableForm

input//Map[{FromCharacterCode[#],#}&,#]&//Map[{#[[1]],IntegerString[#[[2]],16,2]}&,#]&//Partition[#,8,8,{1,1},{}]&//TableForm

input//Map[{FromCharacterCode[#],#}&,#]&//Map[{#[[1]],IntegerString[#[[2]],2,8]}&,#]&//Partition[#,8,8,{1,1},{}]&//TableForm

test=Pad[input];

test//Partition[#,8,8,{1,1},{}]&//IntegerString[#,2,8]&//TableForm

test//Partition[#,8,8,{1,1},{}]&//IntegerString[#,16,2]&//TableForm

IV=Map[FromDigits[#,16]&,{"67452301","EFCDAB89","98BADCFE","10325476"}]

Block[{w=Map[FromDigits[#,256]&,Partition[test,4]]},w]//IntegerString[#,16,8]&//Partition[#,8,8,{1,1},{}]&//TableForm

CompressionFunction[x_,h_]:=
Block[{w=Map[FromDigits[#,256]&,Map[Reverse[#]&,Partition[x,4]]],result},
Block[{a=h[[1]],b=h[[2]],c=h[[3]],d=h[[4]],f,j,k,s,temp},
For[i=1,i≤64,i++,
If[1≤i&&i≤16,
f=BitOr[BitAnd[b,c],BitAnd[Bitnot[b],d]];
s={7,12,17,22}[[Mod[i,4,1]]];
j=i;
];
If[17≤i&&i≤32,
f=BitOr[BitAnd[d,b],BitAnd[Bitnot[d],c]];
s={5,9,14,20}[[Mod[i,4,1]]];
j={2,7,12,1,6,11,16,5,10,15,4,9,14,3,8,13}[[i-16]];
];
If[33≤i&&i≤48,
f=BitXor[b,c,d];
s={4,11,16,23}[[Mod[i,4,1]]];
j={6,9,12,15,2,5,8,11,14,1,4,7,10,13,16,3}[[i-32]];
];
If[49≤i&&i≤64,
f=BitXor[c,BitOr[b,BitNot[d]]];
s={6,10,15,21}[[Mod[i,4,1]]];
j={1,8,15,6,13,4,11,2,9,16,7,14,5,12,3,10}[[i-48]];
];
k=Floor[(2^32) Abs[Sin[i]]];
temp=Bitrotate[Mod[a+f+w[[j]]+k,(2^32)],s];
a=d;
d=c;
c=b;
b=b+temp;
];
result=Mod[h+{a,b,c,d},(2^32)];
];
result
]

CompressionFunction[test,IV]

BaseForm[IV,16]

BaseForm[Map[EndianSwap,CompressionFunction[test,IV]],16]

Table[Floor[(2^32) Abs[Sin[i]]],{i,1,64}]//BaseForm[#,16]&

CompressionFunctionView[x_,h_,base_]:=
Block[{w=Map[FromDigits[#,256]&,Map[Reverse[#]&,Partition[x,4]]],result,state={{"i","a","b","c","d","f","j","k","s","w","temp"}}},
Block[{a=h[[1]],b=h[[2]],c=h[[3]],d=h[[4]],f=0,j=0,k=0,s=0,temp=0},
For[i=1,i≤64,i++,
If[1≤i&&i≤16,
f=BitOr[BitAnd[b,c],BitAnd[Bitnot[b],d]];
s={7,12,17,22}[[Mod[i,4,1]]];
j=i;
];
If[17≤i&&i≤32,
f=BitOr[BitAnd[d,b],BitAnd[Bitnot[d],c]];
s={5,9,14,20}[[Mod[i,4,1]]];
j={2,7,12,1,6,11,16,5,10,15,4,9,14,3,8,13}[[i-16]];
];
If[33≤i&&i≤48,
f=BitXor[b,c,d];
s={4,11,16,23}[[Mod[i,4,1]]];
j={6,9,12,15,2,5,8,11,14,1,4,7,10,13,16,3}[[i-32]];
];
If[49≤i&&i≤64,
f=BitXor[c,BitOr[b,BitNot[d]]];
s={6,10,15,21}[[Mod[i,4,1]]];
j={1,8,15,6,13,4,11,2,9,16,7,14,5,12,3,10}[[i-48]];
];
k=Floor[(2^32) Abs[Sin[i]]];
AppendTo[state,Join[{i-1},IntegerString[{a,b,c,d,f,j,k,s,w[[j]],temp},base,32/Log[2,base]]]];
temp=Bitrotate[Mod[a+f+w[[j]]+k,(2^32)],s];
a=d;
d=c;
c=b;
b=b+temp;
];
AppendTo[state,Join[{"final"},IntegerString[{a,b,c,d,f,j,k,s,0,temp},base,32/Log[2,base]]]];
AppendTo[state,{"i","a","b","c","d","f","j","k","s","w","temp"}];
result=Mod[h+{a,b,c,d},(2^32)];
AppendTo[state,Join[{"output"},IntegerString[result,base,32/Log[2,base]]]];
];
state
]

CompressionFunctionView[test,IV,16]//TableForm

MD5[x_]:=Block[{h=IV,chunks=Partition[Pad[x],64],i},
Do[h=CompressionFunction[chunks[[i]],h],{i,Length[chunks]}];
IntegerString[FromDigits[Map[EndianSwap,h],(2^32)],16]
]

MD5[input]

MD5[Join[input,input]]