the algoritham is working but i just can seem to get the right md5 sum

since im simplyfying it, the algorithm is only taking 64byte of data and returning a pointer to hash

typedef unsigned int INT ; unsigned int t[] = { 0xd76aa478L, /* 1 */ . . . . the sinus results copied from the net . . . 0xbd3af235L, /* 62 */ 0x2ad7d2bbL, /* 63 */ 0xeb86d391L /* 64 */ }; unsigned int r[] = { 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 }; unsigned int leftrotate(INT x,INT c){ return (x << c) | (x >> (32-c)); } unsigned char * md5(unsigned char *input){ unsigned char buff[64]; INT len=strlen((char *)input),w[16],stat[4],f,a,b,c,d,g,i,j,temp; bzero((char *)buff,sizeof(buff)); for(i=0;i<len && i<59;i++){ buff[i]=input[i]; } if(len<59){ buff[len]=0x80; len*=8;} else { buff[59]=0x80; len=59*8; } for(i=0;i<4;i++){ buff[i+60]=len >> (24 - i*8); } for(i=0,j=0;i<16;i++,j+=4){ w[i]=0; w[i]=(((INT)buff[j]<< 24) | ((INT)buff[j+1]<<16) | ((INT)buff[j+2] << 8) | ((INT)buff[j+3])); } stat[0]=0x01234567; stat[1]=0x89abcdef; stat[2]=0xfedcba98; stat[3]=0x76543210; a=stat[0]; b=stat[1]; c=stat[2]; d=stat[3]; for(i=0;i<64;i++){ if (0 <= i && i<= 15 ){ f = (b & c) | ((~ b) & d); g = i; }else if (16 <= i && i<= 31){ f = (d & b) | ((~ d) & c); g = (5*i + 1) % 16; }else if (32 <= i && i<= 47){ f = b ^ c ^ d; g = (3*i + 5) % 16; }else if (48 <= i && i<= 63){ f = c ^ (b | (~ d)); g = (7*i) % 16; } temp = d; d = c; c = b; b = b + leftrotate((a + f + t[i] + w[g]) , r[i]); a = temp; } stat[0]=a + stat[0]; stat[1]=b + stat[1]; stat[2]=c + stat[2]; stat[3]=d + stat[3]; for(i=0;i<4;i++){ printf("%02x",stat[i]); } return input; }

thanks

**Edited by ferovac, 04 August 2010 - 10:57 AM.**