MCPcopy Index your code
hub / github.com/petertodd/python-bitcoinlib / ripemd160

Function ripemd160

bitcoin/core/contrib/ripemd160.py:96–110  ·  view source on GitHub ↗

Compute the RIPEMD-160 hash of data.

(data)

Source from the content-addressed store, hash-verified

94
95
96def ripemd160(data):
97 """Compute the RIPEMD-160 hash of data."""
98 # Initialize state.
99 state = (0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0)
100 # Process full 64-byte blocks in the input.
101 for b in range(len(data) >> 6):
102 state = compress(*state, data[64*b:64*(b+1)])
103 # Construct final blocks (with padding and size).
104 pad = b"\x80" + b"\x00" * ((119 - len(data)) & 63)
105 fin = data[len(data) & ~63:] + pad + (8 * len(data)).to_bytes(8, 'little')
106 # Process final blocks.
107 for b in range(len(fin) >> 6):
108 state = compress(*state, fin[64*b:64*(b+1)])
109 # Produce output.
110 return b"".join((h & 0xffffffff).to_bytes(4, 'little') for h in state)

Callers 3

_EvalScriptFunction · 0.90
Hash160Function · 0.90
test_ripemd160Method · 0.90

Calls 3

compressFunction · 0.85
joinMethod · 0.80
to_bytesMethod · 0.45

Tested by 1

test_ripemd160Method · 0.72