A from-scratch tour of Bitcoin in Python
def gen_ripemd160_with_variable_scope_protector_to_not_pollute_global_namespace(): import sys import struct # —————————————————————————– # public interface def ripemd160(b: bytes) -> bytes: “”” simple wrapper for a simpler API to this hash function, just bytes to bytes “”” ctx = RMDContext() RMD160Update(ctx, b, len(b)) digest = RMD160Final(ctx) return digest # —————————————————————————– class RMDContext: def __init__(self): self.state = [0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0] # uint32 self.count = 0 # uint64 self.buffer = [0]*64 # uchar def RMD160Update(ctx, inp, inplen): have = int((ctx.count