You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

4 years ago
  1. # Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
  2. # Copyright (C) 2011 Nominum, Inc.
  3. #
  4. # Permission to use, copy, modify, and distribute this software and its
  5. # documentation for any purpose with or without fee is hereby granted,
  6. # provided that the above copyright notice and this permission notice
  7. # appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
  10. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
  12. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  15. # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. """Hashing backwards compatibility wrapper"""
  17. import hashlib
  18. import warnings
  19. warnings.warn(
  20. "dns.hash module will be removed in future versions. Please use hashlib instead.",
  21. DeprecationWarning)
  22. hashes = {}
  23. hashes['MD5'] = hashlib.md5
  24. hashes['SHA1'] = hashlib.sha1
  25. hashes['SHA224'] = hashlib.sha224
  26. hashes['SHA256'] = hashlib.sha256
  27. hashes['SHA384'] = hashlib.sha384
  28. hashes['SHA512'] = hashlib.sha512
  29. def get(algorithm):
  30. return hashes[algorithm.upper()]