mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-12 09:38:08 +00:00
17 lines
374 B
Python
17 lines
374 B
Python
|
|
class HashWriter:
|
|
|
|
def __init__(self, hashfunc):
|
|
self.ctx = hashfunc()
|
|
self.buf = bytearray(1) # used in append()
|
|
|
|
def extend(self, buf: bytearray):
|
|
self.ctx.update(buf)
|
|
|
|
def append(self, b: int):
|
|
self.buf[0] = b
|
|
self.ctx.update(self.buf)
|
|
|
|
def get_digest(self, *args) -> bytes:
|
|
return self.ctx.digest(*args)
|