Return a hasher, populated with an initial ``msg`` bytes string. Close on the bitsize and hmodule
(self, msg=None, **kwargs)
| 41 | """A hasher class that behaves like a hashlib module.""" |
| 42 | |
| 43 | def __init__(self, msg=None, **kwargs): |
| 44 | """ |
| 45 | Return a hasher, populated with an initial ``msg`` bytes string. |
| 46 | Close on the bitsize and hmodule |
| 47 | """ |
| 48 | # length of binary digest for this hash |
| 49 | self.digest_size = bitsize // 8 |
| 50 | |
| 51 | # binh = binary hasher module |
| 52 | self.binh = hmodule() |
| 53 | |
| 54 | # msg_len = length in bytes of the message hashed |
| 55 | self.msg_len = 0 |
| 56 | |
| 57 | if msg: |
| 58 | self.update(msg) |
| 59 | |
| 60 | def update(self, msg=None): |
| 61 | """ |