本文整理匯總了Python中dns.hash方法的典型用法代碼示例。如果您正苦於以下問題:Python dns.hash方法的具體用法?Python dns.hash怎麽用?Python dns.hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dns
的用法示例。
在下文中一共展示了dns.hash方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_algorithm
# 需要導入模塊: import dns [as 別名]
# 或者: from dns import hash [as 別名]
def get_algorithm(algorithm):
"""Returns the wire format string and the hash module to use for the
specified TSIG algorithm
@rtype: (string, hash constructor)
@raises NotImplementedError: I{algorithm} is not supported
"""
if isinstance(algorithm, string_types):
algorithm = dns.name.from_text(algorithm)
try:
return (algorithm.to_digestable(), dns.hash.hashes[_hashes[algorithm]])
except KeyError:
raise NotImplementedError("TSIG algorithm " + str(algorithm) +
" is not supported")
示例2: get_algorithm
# 需要導入模塊: import dns [as 別名]
# 或者: from dns import hash [as 別名]
def get_algorithm(algorithm):
"""Returns the wire format string and the hash module to use for the
specified TSIG algorithm
@rtype: (string, hash constructor)
@raises NotImplementedError: I{algorithm} is not supported
"""
global _hashes
if _hashes is None:
_setup_hashes()
if isinstance(algorithm, (str, unicode)):
algorithm = dns.name.from_text(algorithm)
if sys.hexversion < 0x02050200 and \
(algorithm == HMAC_SHA384 or algorithm == HMAC_SHA512):
raise NotImplementedError("TSIG algorithm " + str(algorithm) +
" requires Python 2.5.2 or later")
try:
return (algorithm.to_digestable(), _hashes[algorithm])
except KeyError:
raise NotImplementedError("TSIG algorithm " + str(algorithm) +
" is not supported")
示例3: _maybe_add_hash
# 需要導入模塊: import dns [as 別名]
# 或者: from dns import hash [as 別名]
def _maybe_add_hash(tsig_alg, hash_alg):
try:
_hashes[tsig_alg] = dns.hash.get(hash_alg)
except KeyError:
pass