i cannot find the mistake i made with this code. i have tried many different ways to create ripemd160, but they either don't work or give me wrong outputs.
what did i do wrong?
# makehex() = change the value into a 8 hex char string # ROL i got from another code, and I know it works # little_end() = move each byte (2 hex chars) to the other end of the string def F(x,y,z,round): if round<16: return x ^ y ^ z elif 16<=round<32: return (x & y) | (~x & z) elif 32<=round<48: return (x | ~y) ^ z elif 48<=round<64: return (x & z) | (y & ~z) elif 64<=round: return x ^ (y | ~z) def RIPEMD160(data): # the constants (r, rr, s, ss) should be right. i copied them right off of the original paper and checked them with other codes, and i dont think i found any errors # i know the padding is correct. i copied it from my md4 program, which is also correct # its most likely that something here is wrong for i in range(number of blocks of 512 bits): # single chars are the first round, double is the parallel round a = aa = h0; b = bb = h1; c = cc = h2; d = dd = h3; e = ee = h4 X = data[512*i:512*(i+1)] X = [int(X[32*x:32*(x+1)],2) for x in range(16)] for j in range(80): T = (a+ ROL( (F(b, c, d, j) + X[r[j]] + k[j/16])%2**32,s[j])+e)%2**32 a = e; e = d; d = ROL(c, 10); c = b; a = T T = (aa+ ROL( (F(bb,cc,dd,79-j) + X[rr[j]] + kk[j/16] )%2**32,ss[j])+ee)%2**32 aa = ee; ee = dd; dd = ROL(cc,10); cc = bb; aa = T T = (h1+c+dd)%2**32 h1 = (h2+d+ee)%2**32 h2 = (h3+e+aa)%2**32 h3 = (h4+a+bb)%2**32 h4 = (h0+b+cc)%2**32 h0 = T return little_end(makehex(h0))+little_end(makehex(h1))+little_end(makehex(h2))+little_end(makehex(h3))+little_end(makehex(h4))