本文整理汇总了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