Return a separate copy of this hashing object. An update to this copy won't affect the original object.
(self)
| 152 | inst.update(msg) |
| 153 | |
| 154 | def copy(self): |
| 155 | """Return a separate copy of this hashing object. |
| 156 | |
| 157 | An update to this copy won't affect the original object. |
| 158 | """ |
| 159 | # Call __new__ directly to avoid the expensive __init__. |
| 160 | other = self.__class__.__new__(self.__class__) |
| 161 | other.digest_size = self.digest_size |
| 162 | other.block_size = self.block_size |
| 163 | if self._hmac: |
| 164 | other._hmac = self._hmac.copy() |
| 165 | other._inner = other._outer = None |
| 166 | else: |
| 167 | other._hmac = None |
| 168 | other._inner = self._inner.copy() |
| 169 | other._outer = self._outer.copy() |
| 170 | return other |
| 171 | |
| 172 | def _current(self): |
| 173 | """Return a hash object for the current state. |