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