当前位置: 首页>>代码示例>>Python>>正文


Python hashlib.name方法代码示例

本文整理汇总了Python中hashlib.name方法的典型用法代码示例。如果您正苦于以下问题:Python hashlib.name方法的具体用法?Python hashlib.name怎么用?Python hashlib.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hashlib的用法示例。


在下文中一共展示了hashlib.name方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_large_update

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def test_large_update(self):
        aas = 'a' * 128
        bees = 'b' * 127
        cees = 'c' * 126
        abcs = aas + bees + cees

        for name in self.supported_hash_names:
            m1 = hashlib.new(name)
            m1.update(aas)
            m1.update(bees)
            m1.update(cees)

            m2 = hashlib.new(name)
            m2.update(abcs)
            self.assertEqual(m1.digest(), m2.digest(), name+' update problem.')

            m3 = hashlib.new(name, abcs)
            self.assertEqual(m1.digest(), m3.digest(), name+' new problem.') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_hashlib.py

示例2: check

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def check(self, name, data, hexdigest):
        hexdigest = hexdigest.lower()
        constructors = self.constructors_to_test[name]
        # 2 is for hashlib.name(...) and hashlib.new(name, ...)
        self.assertGreaterEqual(len(constructors), 2)
        for hash_object_constructor in constructors:
            m = hash_object_constructor(data)
            computed = m.hexdigest()
            self.assertEqual(
                    computed, hexdigest,
                    "Hash algorithm %s constructed using %s returned hexdigest"
                    " %r for %d byte input data that should have hashed to %r."
                    % (name, hash_object_constructor,
                       computed, len(data), hexdigest))
            computed = m.digest()
            digest = bytes.fromhex(hexdigest)
            self.assertEqual(computed, digest)
            self.assertEqual(len(digest), m.digest_size) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_hashlib.py

示例3: test_hexdigest

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def test_hexdigest(self):
        for name in self.supported_hash_names:
            h = hashlib.new(name)
            self.assertTrue(hexstr(h.digest()) == h.hexdigest()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_hashlib.py

示例4: check

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def check(self, name, data, digest):
        constructors = self.constructors_to_test[name]
        # 2 is for hashlib.name(...) and hashlib.new(name, ...)
        self.assertGreaterEqual(len(constructors), 2)
        for hash_object_constructor in constructors:
            computed = hash_object_constructor(data).hexdigest()
            self.assertEqual(
                    computed, digest,
                    "Hash algorithm %s constructed using %s returned hexdigest"
                    " %r for %d byte input data that should have hashed to %r."
                    % (name, hash_object_constructor,
                       computed, len(data), digest)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_hashlib.py

示例5: check_update

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def check_update(self, name, data, digest):
        constructors = self.constructors_to_test[name]
        # 2 is for hashlib.name(...) and hashlib.new(name, ...)
        self.assertGreaterEqual(len(constructors), 2)
        for hash_object_constructor in constructors:
            h = hash_object_constructor()
            h.update(data)
            computed = h.hexdigest()
            self.assertEqual(
                    computed, digest,
                    "Hash algorithm %s using %s when updated returned hexdigest"
                    " %r for %d byte input data that should have hashed to %r."
                    % (name, hash_object_constructor,
                       computed, len(data), digest)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:16,代码来源:test_hashlib.py

示例6: test_name_attribute

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def test_name_attribute(self):
        for cons in self.hash_constructors:
            h = cons()
            self.assertIsInstance(h.name, str)
            self.assertIn(h.name, self.supported_hash_names)
            self.assertEqual(h.name, hashlib.new(h.name).name) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_hashlib.py

示例7: check_blocksize_name

# 需要导入模块: import hashlib [as 别名]
# 或者: from hashlib import name [as 别名]
def check_blocksize_name(self, name, block_size=0, digest_size=0):
        constructors = self.constructors_to_test[name]
        for hash_object_constructor in constructors:
            m = hash_object_constructor()
            self.assertEqual(m.block_size, block_size)
            self.assertEqual(m.digest_size, digest_size)
            self.assertEqual(len(m.digest()), digest_size)
            self.assertEqual(m.name, name)
            # split for sha3_512 / _sha3.sha3 object
            self.assertIn(name.split("_")[0], repr(m)) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_hashlib.py


注:本文中的hashlib.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。