def ror7_hash(name): x = 0 for c in name: x = ror(x, 7) & 0xffffffff x += ord(c) x &= 0xffffffff return x
def decrypt(self, block,state = None): S = state if state else self.state A, B, C, D = struct.unpack("<4L", block.ljust(16,"\0"))# * 16) C = _add(C, -S[43]) A = _add(A, -S[42]) for i in range(20,0,-1): # 20..1 A, B, C, D = D, A, B, C u = rol(_mul(D, _add(rol(D, 1) | 1)), 5) t = rol(_mul(B, _add(rol(B, 1) | 1)), 5) C = ror(_add(C, -S[2 * i + 1]), t) ^ u A = ror(_add(A, -S[2 * i]), u) ^ t D = _add(D, -S[1]) B = _add(B, -S[0]) return struct.pack("<4L", A&0xffffffff, B&0xffffffff, C&0xffffffff, D&0xffffffff)#[A,B,C,D]
def ROR16(x, n): return ror(x, n, 16) & 0xFFFF