Return a separate copy of this hashing object. An update to this copy won't affect the original object.
(self)
| 120 | inst.update(msg) |
| 121 | |
| 122 | def copy(self): |
| 123 | """Return a separate copy of this hashing object. |
| 124 | |
| 125 | An update to this copy won't affect the original object. |
| 126 | """ |
| 127 | # Call __new__ directly to avoid the expensive __init__. |
| 128 | other = self.__class__.__new__(self.__class__) |
| 129 | other.digest_size = self.digest_size |
| 130 | if self._hmac: |
| 131 | other._hmac = self._hmac.copy() |
| 132 | other._inner = other._outer = None |
| 133 | else: |
| 134 | other._hmac = None |
| 135 | other._inner = self._inner.copy() |
| 136 | other._outer = self._outer.copy() |
| 137 | return other |
| 138 | |
| 139 | def _current(self): |
| 140 | """Return a hash object for the current state. |