Package dns :: Module hash
[hide private]
[frames] | no frames]

Source Code for Module dns.hash

 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   
20  import hashlib 
21  import warnings 
22   
23  warnings.warn( 
24      "dns.hash module will be removed in future versions. Please use hashlib instead.", 
25      DeprecationWarning) 
26   
27  hashes = {} 
28  hashes['MD5'] = hashlib.md5 
29  hashes['SHA1'] = hashlib.sha1 
30  hashes['SHA224'] = hashlib.sha224 
31  hashes['SHA256'] = hashlib.sha256 
32  hashes['SHA384'] = hashlib.sha384 
33  hashes['SHA512'] = hashlib.sha512 
34   
35   
36 -def get(algorithm):
37 return hashes[algorithm.upper()]
38