cryptography - what is wrong with my ripemd160 python code? -


Whatever I have tried, he has given me incorrect output. I also copied the code and changed it So that they work in dragon and I still get wrong output. If the value is [-1] == 'L': value = hex (value) [2:] if there is a value, is it wrong?

  import os, math def makehex (value, size = 8) value = value [0: -1] while lane (value)  Size: Value = '0' + Value Return Value DEF MacBin (value, size = 32): value = bin (value) [2:] value) & lt; Size: Value = '0' + Value Return Value ROL (Value, N): Return (value  32-n) def little_end (string, base = 16): t = '' if base == 2: s = 8 if the base == 16: s = 2 in the range x (len (string) )) / S): T = String [S * x: s * (x + 1)] + T Return T DF F (x, y, z, round): If round and lieutenant; 16: Returns x ^ Y ^ J Elif 16th lieutenant; = Round & lt; 32: returns (x and y) | (~ X and Z) Elife 32 & Lt; = Round & lt; 48: Returns (x | ~ Y) ^ JL Elife 48th Lieutenant; = Round & lt; 64: Returns (X and Z) | (Y & amp; z) Eleph 64 & lt; = Round: Returns x ^ (y | ~ z) DIP RIPEMD160 (data): # constant h0 = 0x67452301; H1 = 0xEFCDAB89; H2 = 0x98BADCFE; H3 = 0x10325476; H4 = 0xC3D2E1F0 k = [0, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E] KK [[0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9,0] S = [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,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] SS = [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 , 7, 6, 15, 13, 11, 9, 7, 15, 11, 6, 6, 14, 12, 13, 13, 14, 13, 13, 7, 15, 15, 11, 11, 14, 6 , 14, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 13, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11] R = boundary (16) + [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] RR [5, 14, 7, 0, 9, 2, 1, 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] # MD4 Padding + preprocessing temp = 'for data in X: temp + = makebin (ord (x), 8) length = len (temp)% 2 ** 64 temp + =' 1 'while len (temp)% 512! = 448: floating + = '0' input = temporary temp = '' x in the range (32) (x): temp + = little_end (input [32 * x: 32 * (x + 1)], 2) iNPUT = temp temp = Mebin (length 64) input + = temp [32] + temp [32] t = len (input) / 512 # rounds i category: # i parallel round variable 2x second round Variable: a - & gt; Aa aa = aa = h0; B = BB = H1; C = cc = h2; D = DD = H3; E = EE = H4x = Input [512 * i: 512 * (i + 1)] x = [int (x [32 * x: 32 * (x + 1)], 2) For the range in x ( 16]] in the category J (80): T = (A + + RO (F (B, C, D, J) + J [J]] + J [J / 16]% 2 ** 32, S [ J]) + E)% 2 ** 32C = ROL (C, 10) A = E; E = D; D = C; C = B; A = TT = (AA + Aroel (F (BB, CC, DD, 79-j) + x [RR [j]] + KK [J / 16]% 2 ** 32, SS [j]) + EE) % 2 ** 32 cc = ROL (cc, 10) aa = ee; Ee = dd; DD = CC; CC = BB; AA = TT = (H1 + C + DD)% 2 ** 32 H1 = (H2 + D + EE)% 2 ** 32 H2 = (H3 + E + AA)% 2 ** 32 h 3 = (H4 + A + BB)% 2 ** 32 H4 = (H 0 + B + CC)% 2 ** 32 H 0 = t return Thodha_and (Meheks (H 0)) + Km_and (Meheks (H1 )) + Cota_and (Meheks (H 2)) + Cote_and (Meheks (H-3)) + Cote_and (Meheks (H4)) data RIPEMDl60 = ( '') print data, data == '9c1185a5c5e9fc54612808977ee8f548b2258d31' # is always false  

  & gt; & Gt; & Gt; Import Hibbles & gt; & Gt; & Gt; Data = '' & gt; & Gt; & Gt; Hashlib.new ( 'ripemd160', data) .hexdigest () '9c1185a5c5e9fc54612808977ee8f548b2258d31'  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -