python类algorithms_guaranteed()的实例源码

rendezvous.py 文件源码 项目:proxenos 作者: darvid 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def hashex(method,    # type: HashMethod
           key,       # type: KeyType
           **options  # type: typing.Any
           ):
    # type: (...) -> int
    if isinstance(key, six.text_type):
        key = key.encode('utf-8')
    if method.name.lower() in hashlib.algorithms_guaranteed:
        return int(hashlib.new(method.name.lower(), key).hexdigest(), 16)
    elif method == HashMethod.MMH3_32:
        return hash_murmur3(key, size=32, **options)
    elif method == HashMethod.MMH3_64:
        return hash_murmur3(key, size=64, **options)
    elif method == HashMethod.MMH3_128:
        return hash_murmur3(key, size=128, **options)
    elif method == HashMethod.SIPHASH:
        return hash_siphash(key, **options)
test_rendezvous.py 文件源码 项目:proxenos 作者: darvid 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_hashex_hashlib():
    for algorithm in hashlib.algorithms_guaranteed:
        method = getattr(proxenos.rendezvous.HashMethod, algorithm.upper())
        assert (proxenos.rendezvous.hashex(method, 'secret') ==
                int(hashlib.new(algorithm, b'secret').hexdigest(), 16))
test.py 文件源码 项目:rehash 作者: kislyuk 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_basic_statements(self):
        for algorithm in hashlib.algorithms_guaranteed:
            if algorithm.startswith("blake2") or algorithm.startswith("sha3") or algorithm.startswith("shake"):
                with self.assertRaises(Exception):
                    rehash.ResumableHasher(algorithm.lower())
            else:
                print(algorithm)
                self.assert_resumable(rehash.new(algorithm.lower()))
                self.assert_resumable(rehash.new(algorithm.lower(), b"initial_data"))
                self.assert_resumable(rehash.ResumableHasher(algorithm.lower()))
                self.assert_resumable(rehash.ResumableHasher(algorithm.lower(), b"initial_data"))
                self.assert_resumable(getattr(rehash, algorithm)())
                self.assert_resumable(getattr(rehash, algorithm)(b"initial_data"))
test_hashlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
test_hashlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
test_hashlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
utils.py 文件源码 项目:deb-python-proliantutils 作者: openstack 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def _get_hash_object(hash_algo_name):
    """Create a hash object based on given algorithm.

    :param hash_algo_name: name of the hashing algorithm.
    :raises: InvalidInputError, on unsupported or invalid input.
    :returns: a hash object based on the given named algorithm.
    """
    algorithms = (hashlib.algorithms_guaranteed if six.PY3
                  else hashlib.algorithms)
    if hash_algo_name not in algorithms:
        msg = ("Unsupported/Invalid hash name '%s' provided."
               % hash_algo_name)
        raise exception.InvalidInputError(msg)

    return getattr(hashlib, hash_algo_name)()
test_hashlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
crypto.py 文件源码 项目:ricedb 作者: TheReverend403 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def hash(self, mask, target, args):
        """Hash text.

            %%hash (--md5 | --sha1 | --sha256 | --sha512) <string>...
        """
        available_algorithms = hashlib.algorithms_guaranteed
        text = ' '.join(args['<string>']).encode('UTF-8')
        for algo in available_algorithms:
            flag = '--{0}'.format(algo)
            if flag in args and args[flag]:
                hash_object = hashlib.new(algo)
                hash_object.update(text)
                return '{0}: {1}'.format(mask.nick, hash_object.hexdigest())
test_hashlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
test_hashlib.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))
test_hashlib.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def test_algorithms_guaranteed(self):
        self.assertEqual(hashlib.algorithms_guaranteed,
            set(_algo for _algo in self.supported_hash_names
                  if _algo.islower()))
test_hashlib.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def test_algorithms_available(self):
        self.assertTrue(set(hashlib.algorithms_guaranteed).
                            issubset(hashlib.algorithms_available))


问题


面经


文章

微信
公众号

扫码关注公众号