[Berry Schoenmakers, January 2005. Updated February 2017.]
The collisions for RIPEMD, MD4, MD5 (by Xiaoyun Wang et al.) and for SHA-0 (by Antoine Joux et al.), as reported in August 2004,  are confirmed below; details on these attacks appeared at Eurocrypt 2005.
The collision for SHA-1 (by Marc Stevens et al.), as reported in February 2017, is also confirmed. See https://shattered.io/.
To confirm the collisions, this notebook collects Mathematica implementations of the following well-known hash functions (collisions are known only for the marked hash functions):
	RIPEMD*
	MD4*
	MD5*
	RIPEMD128
	RIPEMD160
	SHA-0*
	SHA-1*. 
The emphasis is on simplicity, not on efficiency. The input to each hash function is simply a bit string (i.e., a list of 0/1 values), whereas the output is represented as an integer between 0 and 2^k-1 where k is the output length of the hash function. 

The implementations have all been tested on these standard test vectors: 
	""    (empty input)
	"a"
	"abc"
	"message digest"
	"abcdefghijklmnopqrstuvwxyz"
	"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
	"12345678901234567890123456789012345678901234567890123456789012345678901234567890"

BitRotateLeft[x_,n_] := FromDigits[ RotateLeft[IntegerDigits[x,2,32],n],2];
convert[x_] := FromDigits[Reverse[IntegerDigits[x,256,4]],256];
testVector[y_,h_,s_] := Module[{x},
x = Flatten[IntegerDigits[ToCharacterCode[s],2,8]];
If[h[x]==y, Print["OK: output ",BaseForm[y,16]," for ", h," on input '",s,"'."];, 
Print["!!!!! Problem: output ",BaseForm[h[x],16]," for ", h," on input '",s,"'."];]
];
testCollision[h_,m1_,m2_] := Module[{x1,x2},
If[h==sha0||h==sha1 ,
x1= Flatten[IntegerDigits[IntegerDigits[m1,2^32],2,32]];
x2 = Flatten[IntegerDigits[IntegerDigits[m2,2^32],2,32]];];
If[h==ripemd || h==md4 || h==md5,
x1 = Flatten[IntegerDigits[convert/@IntegerDigits[m1,2^32],2,32]];
x2 = Flatten[IntegerDigits[convert/@IntegerDigits[m2,2^32],2,32]];];
If[h[x1]==h[x2], Print["Collision with output ",BaseForm[h[x1],16]," for ", h," on inputs ",BaseForm[m1,16]," and ",BaseForm[m2,16],"."];, 
Print["!!!!! Sorry, no collision ????"];]
];

ripemd[x_]:=Module[{f,y,z,s,h1,h2,h3,h4,a,b,c,d,t,m,X,r,xx,i,j,k},
f[j_,u_,v_,w_]:= 
If[j≤16, BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]], 
If[j≤32,  BitOr[BitAnd[u,v],BitAnd[u,w],BitAnd[v,w]],
BitXor[u,v,w]]];
y[0,j_] := y[0,j] =If[j≤16, 0, If[j≤32, 16^^5a827999, 16^^6ed9eba1]];
y[1,j_] := y[1,j] =If[j≤16, 16^^50a28be6, If[j≤32, 0,16^^5c4dd124]];
z=Flatten[{{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},{7,4,13,1,10,6,15,3,12,0,9,5,14,2,11,8},
{3,10,2,4,9,15,8,1,14,7,0,6,11,13,5,12}}];
s=Flatten[{{11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8},{7,6,8,13,11,9,7,15,7,12,15,9,7,11,13,12},{11,13,14,7,14,9,13,15,6,8,13,6,12,5,7,5}}];
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],Flatten[IntegerDigits[Reverse[IntegerDigits[Mod[Length[x],2^64],256,8]],2,8]]];
{h1,h2,h3,h4} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2];];
For[k=0,k≤1,k++,
{a[k],b[k],c[k],d[k]} = {h1,h2,h3,h4};
For[j=1, j≤48, j++, 
t = BitRotateLeft[Mod[a[k] + f[j,b[k],c[k],d[k]] +convert[ X[z[[j]]]] + y[k,j],2^32],s[[j]]];
{a[k],b[k],c[k],d[k]} = {d[k],t,b[k],c[k]};
];
];
{h1,h2,h3,h4}=Mod[{h2+c[0]+d[1],h3+d[0]+a[1],h4+a[0]+b[1],h1+b[0]+c[1]},2^32];
];
FromDigits[convert/@{h1,h2,h3,h4},2^32]
];
testVector[16^^9f73aa9b372a9dacfb86a6108852e2d9,ripemd,""];
testVector[16^^486f74f790bc95ef7963cd2382b4bbc9,ripemd,"a"];
testVector[16^^3f14bad4c2f9b0ea805e5485d3d6882d,ripemd,"abc"];
testVector[16^^5f5c7ebe1abbb3c7036482942d5f9d49,ripemd,"message digest"];
testVector[16^^ff6e1547494251a1cca6f005a6eaa2b4,ripemd,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^ff418a5aed3763d8f2ddf88a29e62486,ripemd,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^dfd6b45f60fe79bbbde87c6bfc6580a5,ripemd,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
m1=16^^579faf8e09ecf579574a6aba78413511a2b410a4ad2f6c9f0b56202c4d7579110bdeaae778bc91f247bc6d7d9abdd1b1a45d2015817104ff264758a861064ea5;
m1a=16^^579faf8e09ecf579574a6aba78513511a2b410a4ad2f6c9f0b56202c4d7579110bdeaae778bc91f2c7c06d7d9abdd1b1a45d2015817104ff264758a8e1064ea5;
m2=16^^579faf8e09ecf579574a6aba78413511a2b410a4ad2f6c9f0b56202c4d7579110bdeaae778bc91f247bc6d7d9abdd1b1a45d2015a0a504ffb18d58a8e70c66b6;
m2a=16^^579faf8e09ecf579574a6aba78513511a2b410a4ad2f6c9f0b56202c4d7579110bdeaae778bc91f2c7c06d7d9abdd1b1a45d2015a0a504ffb18d58a8670c66b6;
testCollision[ripemd,m1,m1a];
testCollision[ripemd,m2,m2a];

md4[x_]:=Module[{f,y,z,s,h1,h2,h3,h4,a,b,c,d,t,m,X,r,xx},
f[j_,u_,v_,w_]:= 
If[j≤16,  BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]],  
If[j≤32,  BitOr[BitAnd[u,v],BitAnd[u,w],BitAnd[v,w]],
BitXor[u,v,w]
]];
y[j_] := y[j] =If[j≤16, 0, If[j≤32, 16^^5a827999, 16^^6ed9eba1 ]];
z = {0,1,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15,0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15};
s = {3, 7, 11, 19, 3, 7, 11, 19, 3, 7, 11, 19, 3, 7, 11, 19,3, 5, 9, 13, 3, 5, 9, 13, 3, 5, 9, 13, 3, 5, 9, 13,3, 9, 11, 15, 3, 9, 11, 15, 3, 9, 11, 15, 3, 9, 11, 15};
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],Flatten[IntegerDigits[Reverse[IntegerDigits[Mod[Length[x],2^64],256,8]],2,8]]];
{h1,h2,h3,h4} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2]];
{a,b,c,d} = {h1,h2,h3,h4};
For[j=1, j≤48, j++, t= BitRotateLeft[ Mod[ a + f[j,b,c,d] + convert[X[z[[j]]]] + y[j],2^32],s[[j]]];
{a,b,c,d} = {d,t,b,c};];
{h1,h2,h3,h4}=Mod[{h1,h2,h3,h4}+{a,b,c,d},2^32];
];
FromDigits[convert /@{h1,h2,h3,h4},2^32]
];

testVector[16^^31d6cfe0d16ae931b73c59d7e0c089c0,md4,""]
testVector[16^^bde52cb31de33e46245e05fbdbd6fb24,md4,"a"]
testVector[16^^a448017aaf21d8525fc10ae87aa6729d,md4,"abc"];
testVector[16^^d9130a8164549fe818874806e1c7014b,md4,"message digest"];
testVector[16^^d79e1c308aa5bbcdeea8ed63df412da9,md4,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^043f8582f241db351ce627e153e7f0e4,md4,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^e33b4ddc9c38f2199c3e7b164fcc0536,md4,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
m1=16^^4d7a9c8356cb927ab9d5a57857a7a5eede748a3cdcc366b3b683a0203b2a5d9fc69d71b3f9e99198d79f805ea63bb2e845dd8e3197e31fe52794bf08b9e8c3e9;
m1a=16^^4d7a9c83d6cb927a29d5a57857a7a5eede748a3cdcc366b3b683a0203b2a5d9fc69d71b3f9e99198d79f805ea63bb2e845dc8e3197e31fe52794bf08b9e8c3e9;
m2=16^^4d7a9c8356cb927ab9d5a57857a7a5eede748a3cdcc366b3b683a0203b2a5d9fc69d71b3f9e99198d79f805ea63bb2e845dd8e3197e31fe5f713c240a7b8cf69;
m2a=16^^4d7a9c83d6cb927a29d5a57857a7a5eede748a3cdcc366b3b683a0203b2a5d9fc69d71b3f9e99198d79f805ea63bb2e845dc8e3197e31fe5f713c240a7b8cf69;
testCollision[md4,m1,m1a];
testCollision[md4,m2,m2a];

md5[x_]:=Module[{f,y,z,s,h1,h2,h3,h4,a,b,c,d,t,m,X,r,xx},
f[j_,u_,v_,w_]:= 
If[j≤16,  BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]],  
If[j≤32, BitOr[BitAnd[u,w],BitAnd[v,BitNot[w]]],
If[j≤48, BitXor[u,v,w],
BitXor[v,BitOr[u,BitNot[w]]],
]]];
y[j_] := y[j] = Floor[2^32N[ Abs[Sin[j]],20]];
z={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9}; 
s={7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21};
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],Flatten[IntegerDigits[Reverse[IntegerDigits[Mod[Length[x],2^64],256,8]],2,8]]];
{h1,h2,h3,h4} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2]];
{a,b,c,d} = {h1,h2,h3,h4};
For[j=1, j≤64, j++, t = Mod[ a + f[j,b,c,d] + convert[X[z[[j]]]] + y[j],2^32];
{a,b,c,d} = {d,Mod[b + BitRotateLeft[t,s[[j]]],2^32],b,c};];
{h1,h2,h3,h4}=Mod[{h1,h2,h3,h4}+{a,b,c,d},2^32];
];
FromDigits[convert /@{h1,h2,h3,h4},2^32]
];
testVector[16^^d41d8cd98f00b204e9800998ecf8427e,md5,""]
testVector[16^^0cc175b9c0f1b6a831c399e269772661,md5,"a"]
testVector[16^^900150983cd24fb0d6963f7d28e17f72,md5,"abc"];
testVector[16^^f96b697d7cb7938d525a2f31aaf161d0,md5,"message digest"];
testVector[16^^c3fcd3d76192e4007dfb496cca67e13b,md5,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^d174ab98d277d9f5a5611c2c9f419d9f,md5,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^57edf4a22be3c955ac49da2e2107b67a,md5,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
m1=16^^02dd31d1c4eee6c5069a3d695cf9af9887b5ca2fab7e46123e580440897ffbb80634ad5502b3f4098388e4835a417125e82551089fc9cdf7f2bd1dd95b3c3780d11d0b969c7b41dcf497d8e4d555655ac79a73350cfdebf066f129308fb109d1797f2775eb5cd530baade8225c15cc79ddcb74ed6dd3c55fd80a9bb1e3a7cc35;
m1a=16^^02dd31d1c4eee6c5069a3d695cf9af9807b5ca2fab7e46123e580440897ffbb80634ad5502b3f4098388e4835a41f125e82551089fc9cdf772bd1dd95b3c3780d11d0b969c7b41dcf497d8e4d555655a479a73350cfdebf066f129308fb109d1797f2775eb5cd530baade8225c154c79ddcb74ed6dd3c55f580a9bb1e3a7cc35;
m2=16^^02dd31d1c4eee6c5069a3d695cf9af9887b5ca2fab7e46123e580440897ffbb80634ad5502b3f4098388e4835a417125e82551089fc9cdf7f2bd1dd95b3c3780313e82d85b8f3456d4ac6daec619c936b4e253ddfd03da8706633902a0cd48d242339fe9e87e570f70b654ce1e0da880bc2198c69383a8b62b65f996702af76f;
m2a=16^^02dd31d1c4eee6c5069a3d695cf9af9807b5ca2fab7e46123e580440897ffbb80634ad5502b3f4098388e4835a41f125e82551089fc9cdf772bd1dd95b3c3780313e82d85b8f3456d4ac6daec619c93634e253ddfd03da8706633902a0cd48d242339fe9e87e570f70b654ce1e0d2880bc2198c69383a8b6ab65f996702af76f;
testCollision[md5,m1,m1a];
testCollision[md5,m2,m2a];

ripemd128[x_]:=Module[{f,y,z,s,h1,h2,h3,h4,a,b,c,d,t,m,X,r,xx,i,j,k},
f[j_,u_,v_,w_]:= 
If[j≤16, BitXor[u,v,w],
If[j≤32,  BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]],  
If[j≤48,  BitXor[BitOr[u,BitNot[v]],w],
BitOr[BitAnd[u,w],BitAnd[v,BitNot[w]]]
]]];
y[0,j_] := y[0,j] =If[j≤16, 0, If[j≤32, 16^^5a827999, If[j≤48, 16^^6ed9eba1, 16^^8f1bbcdc]]];
y[1,j_] := y[1,j] =If[j≤16, 16^^50a28be6, If[j≤32, 16^^5c4dd124, If[j≤48, 16^^6d703ef3,0]]];
z[0]=Flatten[{{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},{7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8},
{3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12},{1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2}}];
z[1]=Flatten[{{5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12},{6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2},{15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13},{8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14}}];
s[0]=Flatten[{{11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8},{7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12},{11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5},{11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12}}];
s[1]=Flatten[{{8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6},{9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11},{9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5},{15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8}}];
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],Flatten[IntegerDigits[Reverse[IntegerDigits[Mod[Length[x],2^64],256,8]],2,8]]];
{h1,h2,h3,h4} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2];];
For[k=0,k≤1,k++,
{a[k],b[k],c[k],d[k]} = {h1,h2,h3,h4};
For[j=1, j≤64, j++, 
t = BitRotateLeft[Mod[a[k] + f[(1-k) j+k(65-j),b[k],c[k],d[k]] +convert[ X[z[k][[j]]]] + y[k,j],2^32],s[k][[j]]];
{a[k],b[k],c[k],d[k]} = {d[k],t,b[k],c[k]};
];
];
{h1,h2,h3,h4}=Mod[{h2+c[0]+d[1],h3+d[0]+a[1],h4+a[0]+b[1],h1+b[0]+c[1]},2^32];
];
FromDigits[convert/@{h1,h2,h3,h4},2^32]
];
testVector[16^^cdf26213a150dc3ecb610f18f6b38b46,ripemd128,""];
testVector[16^^86be7afa339d0fc7cfc785e72f578d33,ripemd128,"a"];
testVector[16^^c14a12199c66e4ba84636b0f69144c77,ripemd128,"abc"];
testVector[16^^9e327b3d6e523062afc1132d7df9d1b8,ripemd128,"message digest"];
testVector[16^^fd2aa607f71dc8f510714922b371834e,ripemd128,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^d1e959eb179c911faea4624c60c5c702,ripemd128,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^3f45ef194732c2dbb2c4a2c769795fa3,ripemd128,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];

ripemd160[x_]:=Module[{f,y,z,s,h1,h2,h3,h4,h5,a,b,c,d,e,t,m,X,r,xx,i,j,k},
f[j_,u_,v_,w_]:= 
If[j≤16, BitXor[u,v,w],
If[j≤32,  BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]],  
If[j≤48,  BitXor[BitOr[u,BitNot[v]],w],
If[j≤64, BitOr[BitAnd[u,w],BitAnd[v,BitNot[w]]],
BitXor[u,BitOr[v,BitNot[w]]]
]]]];
y[0,j_] := y[0,j] =If[j≤16, 0, If[j≤32, 16^^5a827999, If[j≤48, 16^^6ed9eba1, If[j≤64,16^^8f1bbcdc,16^^a953fd4e]] ]];
y[1,j_] := y[1,j] =If[j≤16, 16^^50a28be6, If[j≤32, 16^^5c4dd124, If[j≤48, 16^^6d703ef3, If[j≤64,16^^7a6d76e9,0]] ]];
z[0]=Flatten[{{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},{7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8},
{3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12},{1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2},{4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13}}];
z[1]=Flatten[{{5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12},{6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2},{15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13},{8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14},{12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11}}];
s[0]=Flatten[{{11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8},{7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12},{11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5},{11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12},{9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6}}];
s[1]=Flatten[{{8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6},{9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11},{9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5},{15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8},{8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11}}];
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],Flatten[IntegerDigits[Reverse[IntegerDigits[Mod[Length[x],2^64],256,8]],2,8]]];
{h1,h2,h3,h4,h5} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476,16^^c3d2e1f0};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2];];
For[k=0,k≤1,k++,
{a[k],b[k],c[k],d[k],e[k]} = {h1,h2,h3,h4,h5};
For[j=1, j≤80, j++, t = Mod[a[k] + f[(1-k) j+k(81-j),b[k],c[k],d[k]] +convert[ X[z[k][[j]]]] + y[k,j],2^32];
(*Print[j, " ", (1-k) j+k(81-j), " ", z[k][[j]], " ", s[k][[j]] , " ", BaseForm[y[k,j],16]]; *)
{a[k],b[k],c[k],d[k],e[k]} = {e[k],Mod[e[k]+BitRotateLeft[t,s[k][[j]]],2^32],b[k],BitRotateLeft[c[k],10],d[k]};
];
];
{h1,h2,h3,h4,h5}=Mod[{h2+c[0]+d[1],h3+d[0]+e[1],h4+e[0]+a[1],h5+a[0]+b[1],h1+b[0]+c[1]},2^32];
];
FromDigits[convert/@{h1,h2,h3,h4,h5},2^32]
];
testVector[16^^9c1185a5c5e9fc54612808977ee8f548b2258d31,ripemd160,""];
testVector[16^^0bdc9d2d256b3ee9daae347be6f4dc835a467ffe,ripemd160,"a"];
testVector[16^^8eb208f7e05d987a9b044a8e98c6b087f15a0bfc,ripemd160,"abc"];
testVector[16^^5d0689ef49d2fae572b881b123a85ffa21595f36,ripemd160,"message digest"];
testVector[16^^f71c27109c692c1b56bbdceb5b9d2865b3708dbc,ripemd160,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^b0e20b6e3116640286ed3a87a5713079b21f5189,ripemd160,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^9b752e45573d4b39f4dbd3323cab82bf63326bfb,ripemd160,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];

(* Input z ∈ {0,1} for SHA-0 and SHA-1 resp. Input x is bit string to be hashed.*)  
sha[z_,x_]:=Module[{h1,h2,h3,h4,h5,a,b,c,d,e,t,m,X,r,xx},
f[j_,u_,v_,w_]:=
 If[j<20,  BitOr[BitAnd[u,v],BitAnd[BitNot[u],w]],
If[j<40 || j≥60, BitXor[u,v,w],
 BitOr[BitAnd[u,v],BitAnd[u,w],BitAnd[v,w]],
]];
y[1] := y[1] = 16^^5a827999;
y[2] := y[2] = 16^^6ed9eba1;
y[3] := y[3] = 16^^8f1bbcdc;
y[4] := y[4] = 16^^ca62c1d6;
m=Ceiling[(Length[x]+65)/512];
r = 512m-Length[x]-64;
xx =  Join[x,{1},Table[0,{r-1}],IntegerDigits[Mod[Length[x],2^64],2,64]];
{h1,h2,h3,h4,h5} = {16^^67452301,16^^efcdab89,16^^98badcfe,16^^10325476,16^^c3d2e1f0};
For[i=0, i<m, i++,
For[j=0, j<16, j++, X[j]=FromDigits[Take[xx,512i+32j+{1,32}],2]];
For[j=16,j<80,j++, X[j] = BitRotateLeft[BitXor[X[j-3],X[j-8],X[j-14],X[j-16]] ,z]];
{a,b,c,d,e} = {h1,h2,h3,h4,h5};
For[j=0, j<80, j++, t = Mod[ BitRotateLeft[a,5] + f[j,b,c,d]+e+X[j]+y[1+Quotient[j,20]],2^32];
{a,b,c,d,e} = {t,a,BitRotateLeft[b,30],c,d};];
{h1,h2,h3,h4,h5}=Mod[{h1,h2,h3,h4,h5}+{a,b,c,d,e},2^32];
];
FromDigits[{h1,h2,h3,h4,h5},2^32]
];
sha0[x_] := sha[0,x];
testVector[16^^f96cea198ad1dd5617ac084a3d92c6107708c0ef,sha0,""];
testVector[16^^37f297772fae4cb1ba39b6cf9cf0381180bd62f2,sha0,"a"];
testVector[16^^0164b8a914cd2a5e74c4f7ff082c4d97f1edf880,sha0,"abc"];
testVector[16^^c1b0f222d150ebb9aa36a40cafdc8bcbed830b14,sha0,"message digest"];
testVector[16^^b40ce07a430cfd3c033039b9fe9afec95dc1bdcd,sha0,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^79e966f7a3a990df33e40e3d7f8f18d2caebadfa,sha0,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^4aa29d14d171522ece47bee8957e35a41f3e9cff,sha0,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
m1=16^^0a766a602b65cffe773bcf25826b322b3d01b1a972684ef533e3b4b7f53fe376224c08e47e959b2bc3b519880b9286568247d110f70f5c5e2b4590ca3f55f52feeffd4c8fe68de835329e603cc51e7f02545410d1671d108df5a4000dcf20a4394949d72cd14fbb0345cf3a295dcda89f998f87552c9a58b1bdc384835e477185f96e68bebb0025d2d2b69edf21724198f688b41deb9b4913fbe696b5457ab39921e1d7591f89de8457e8613c6c9e3b242879d4d8783b2d9ca9935ea526a729c06edfc50137e69330be976012cc5dfe1c14c4c68bd1db3ecb24438a59a09b5db435563e0d8bdf572f77b53065cef31f32dc9dbaa04146261e9994bd5cd0758e3d;
m1a=16^^0a766a602b65cffe773bcf25826b322b1d01b1ad72684ef51be3b4b7fd3fe3762a4c08e45e959b2fc3b51988039286528a47d110d70f5c5e034590ce3755f52fc6ffd4c8d668de875329e603e451e7f02d45410d1e71d108df5a4000dcf20a4394949d72cd14fbb0145cf3a695dcda89d198f8755ac9a58b13dc384815e4771c5796e68febb0025d052b69edda17241d87688b41f6b9b49117be696f5c57ab399a1e1d7199f89de8657e8613cec9e3b26a879d498783b2d9e29935ea7a6a729806edfc50337e693303e9760104c5dfe5c14c4c68951db3ecba4438a59209b5db435563e0d8bdf572f77b53065cef31f30dc9dbae04146261c1994bd5c50758e3d;
testCollision[sha0,m1,m1a];

sha1[x_] := sha[1,x];
testVector[16^^da39a3ee5e6b4b0d3255bfef95601890afd80709,sha1,""];
testVector[16^^86f7e437faa5a7fce15d1ddcb9eaeaea377667b8,sha1,"a"];
testVector[16^^a9993e364706816aba3e25717850c26c9cd0d89d,sha1,"abc"];
testVector[16^^c12252ceda8be8994d5fa0290a47231c1d16aae3,sha1,"message digest"];
testVector[16^^32d10c7b8cf96570ca04ce37f2a19d84240d3a89,sha1,"abcdefghijklmnopqrstuvwxyz"];
testVector[16^^761c457bf73b14d27e9e9265c46f4b4dda11f940,sha1,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"];
testVector[16^^50abf5706a150990a08b2c5ea40fa0e585554732,sha1,"12345678901234567890123456789012345678901234567890123456789012345678901234567890"];
m0=16^^255044462d312e330a25e2e3cfd30a0a0a312030206f626a0a3c3c2f57696474682032203020522f4865696768742033203020522f547970652034203020522f537562747970652035203020522f46696c7465722036203020522f436f6c6f7253706163652037203020522f4c656e6774682038203020522f42697473506572436f6d706f6e656e7420383e3e0a73747265616d0affd8fffe00245348412d3120697320646561642121212121852fec092339759c39b1a1c63c4c97e1fffe01;
m1=BitShiftLeft[m0,1024]+16^^7f46dc93a6b67e013b029aaa1db2560b45ca67d688c7f84b8c4c791fe02b3df614f86db1690901c56b45c1530afedfb76038e972722fe7ad728f0e4904e046c230570fe9d41398abe12ef5bc942be33542a4802d98b5d70f2a332ec37fac3514e74ddc0f2cc1a874cd0c78305a21566461309789606bd0bf3f98cda8044629a1;
m1a=BitShiftLeft[m0,1024]+16^^7346dc9166b67e118f029ab621b2560ff9ca67cca8c7f85ba84c79030c2b3de218f86db3a90901d5df45c14f26fedfb3dc38e96ac22fe7bd728f0e45bce046d23c570feb141398bb552ef5a0a82be331fea48037b8b5d71f0e332edf93ac3500eb4ddc0decc1a864790c782c76215660dd309791d06bd0af3f98cda4bc4629b1;
testCollision[sha1,m1,m1a];