hasher.py 732 B

12345678910111213141516171819202122232425262728293031323334
  1. import hashlib
  2. def hash_with_md5(string):
  3. hash = hashlib.md5()
  4. string = string.encode('utf-8')
  5. hash.update(string)
  6. return hash
  7. def hash_with_sha1(string):
  8. hash = hashlib.sha1()
  9. string = string.encode('utf-8')
  10. hash.update(string)
  11. return hash
  12. def hash_with_sha224(string):
  13. hash = hashlib.sha224()
  14. string = string.encode('utf-8')
  15. hash.update(string)
  16. return hash
  17. def hash_with_sha256(string):
  18. hash = hashlib.sha256()
  19. string = string.encode('utf-8')
  20. hash.update(string)
  21. return hash
  22. def hash_with_sha512(string):
  23. hash = hashlib.sha512()
  24. string = string.encode('utf-8')
  25. hash.update(string)
  26. return hash
  27. def display_hash(hash):
  28. print(hash.hexdigest())