crypto_4.py 402 B

123456789101112
  1. def __init__(self, data=None, truncate_to=None):
  2. """ SHA-265d against length-extensions-attacks
  3. with optional truncation of the hash
  4. Args:
  5. data: Initial string, optional
  6. truncate_to: length to truncate the hash to, optional
  7. """
  8. self.h = sha256()
  9. self.truncate_to = truncate_to
  10. if data:
  11. self.h.update(data)