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


Python _sha256.sha256方法代码示例

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


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

示例1: test_sha256_sanity

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def test_sha256_sanity(self):
        x = _sha256.sha256()
        self.assertEqual(x.block_size, 64)
        self.assertEqual(x.digest(),
                "\xe3\xb0\xc4B\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99o\xb9$'\xaeA\xe4d\x9b\x93L\xa4\x95\x99\x1bxR\xb8U")
        self.assertEqual(x.digest_size, 32)
        self.assertEqual(x.digest_size, x.digestsize)
        self.assertEqual(x.hexdigest(),
                'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
        self.assertEqual(x.name, "SHA256")
        x.update("abc")
        self.assertEqual(x.hexdigest(),
                'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')

        x_copy = x.copy()
        self.assertTrue(x!=x_copy)
        self.assertEqual(x.hexdigest(), x_copy.hexdigest()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test__sha256.py

示例2: __get_builtin_constructor

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def __get_builtin_constructor(name):
    if name in ('SHA1', 'sha1'):
        import _sha
        return _sha.new
    elif name in ('MD5', 'md5'):
        import _md5
        return _md5.new
    elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
        import _sha256
        bs = name[3:]
        if bs == '256':
            return _sha256.sha256
        elif bs == '224':
            return _sha256.sha224
    elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
        import _sha512
        bs = name[3:]
        if bs == '512':
            return _sha512.sha512
        elif bs == '384':
            return _sha512.sha384

    raise ValueError('unsupported hash type %s' % name) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:hashlib.py

示例3: test_sha256_sanity

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def test_sha256_sanity(self):
        x = _sha256.sha256()
        self.assertEqual(x.block_size, 64)
        self.assertEqual(x.digest(),
                b"\xe3\xb0\xc4B\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99o\xb9$'\xaeA\xe4d\x9b\x93L\xa4\x95\x99\x1bxR\xb8U")
        self.assertEqual(x.digest_size, 32)
        self.assertEqual(x.hexdigest(),
                'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
        self.assertEqual(x.name, "sha256")
        x.update(b"abc")
        self.assertEqual(x.hexdigest(),
                'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad')

        x_copy = x.copy()
        self.assertTrue(x!=x_copy)
        self.assertEqual(x.hexdigest(), x_copy.hexdigest()) 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:18,代码来源:test__sha256.py

示例4: __get_builtin_constructor

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def __get_builtin_constructor(name):
    if name in ('SHA1', 'sha1'):
        import _sha
        return _sha.new
    elif name in ('MD5', 'md5'):
        import _md5
        return _md5.new
    elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
        import _sha256
        bs = name[3:]
        if bs == '256':
            return _sha256.sha256
        elif bs == '224':
            return _sha256.sha224
    elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
        import _sha512
        bs = name[3:]
        if bs == '512':
            return _sha512.sha512
        elif bs == '384':
            return _sha512.sha384

    raise ValueError, "unsupported hash type" 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:25,代码来源:hashlib.py

示例5: get_public_key_sha256

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def get_public_key_sha256(certificate: x509.Certificate) -> bytes:
    pub_bytes = certificate.public_key().public_bytes(encoding=Encoding.DER, format=PublicFormat.SubjectPublicKeyInfo)
    digest = sha256(pub_bytes).digest()
    return digest 
开发者ID:nabla-c0d3,项目名称:sslyze,代码行数:6,代码来源:_certificate_utils.py

示例6: __get_builtin_constructor

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def __get_builtin_constructor(name):
    try:
        if name in ('SHA1', 'sha1'):
            import _sha
            return _sha.new
        elif name in ('MD5', 'md5'):
            import _md5
            return _md5.new
        elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
            import _sha256
            bs = name[3:]
            if bs == '256':
                return _sha256.sha256
            elif bs == '224':
                return _sha256.sha224
        elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
            import _sha512
            bs = name[3:]
            if bs == '512':
                return _sha512.sha512
            elif bs == '384':
                return _sha512.sha384
    except ImportError:
        pass  # no extension module, this hash is unsupported.

    raise ValueError('unsupported hash type %s' % name) 
开发者ID:glmcdona,项目名称:meddle,代码行数:28,代码来源:hashlib.py

示例7: __get_builtin_constructor

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def __get_builtin_constructor(name):
    try:
        if name in ('SHA1', 'sha1'):
            import _sha
            return _sha.new
        elif name in ('MD5', 'md5'):
            import _md5
            return _md5.new
        elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
            import _sha256
            bs = name[3:]
            if bs == '256':
                return _sha256.sha256
            elif bs == '224':
                return _sha256.sha224
        elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
            import _sha512
            bs = name[3:]
            if bs == '512':
                return _sha512.sha512
            elif bs == '384':
                return _sha512.sha384
    except ImportError:
        pass  # no extension module, this hash is unsupported.

    raise ValueError('unsupported hash type ' + name) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:28,代码来源:hashlib.py

示例8: test_sanity

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def test_sanity(self):
        self.assertTrue("__doc__" in dir(_sha256))
        if is_cli:
            self.assertEqual(_sha256.__doc__, "SHA256 hash algorithm")
        self.assertTrue("__name__" in dir(_sha256))
        self.assertTrue("sha224" in dir (_sha256))
        self.assertTrue("sha256" in dir(_sha256))
        #http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21920
        self.assertEqual(len(dir(_sha256)), 5, "there should be 5 attributes in the _sha256 module") 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:test__sha256.py

示例9: test_bytes_hashing

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def test_bytes_hashing(self):
        """test interaction of bytes w/ hashing modules"""
        import _sha, _sha256, _sha512, _md5
        
        for hashLib in (_sha.new, _sha256.sha256, _sha512.sha512, _sha512.sha384, _md5.new):
            x = hashLib(b'abc')
            x.update(b'abc')
            
            #For now just make sure this doesn't throw
            temp = hashLib(bytearray(b'abc'))
            x.update(bytearray(b'abc')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_bytes.py

示例10: __get_builtin_constructor

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def __get_builtin_constructor(name):
    cache = __builtin_constructor_cache
    constructor = cache.get(name)
    if constructor is not None:
        return constructor
    try:
        if name in ('SHA1', 'sha1'):
            import _sha1
            cache['SHA1'] = cache['sha1'] = _sha1.sha1
        elif name in ('MD5', 'md5'):
            import _md5
            cache['MD5'] = cache['md5'] = _md5.md5
        elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
            import _sha256
            cache['SHA224'] = cache['sha224'] = _sha256.sha224
            cache['SHA256'] = cache['sha256'] = _sha256.sha256
        elif name in ('SHA512', 'sha512', 'SHA384', 'sha384'):
            import _sha512
            cache['SHA384'] = cache['sha384'] = _sha512.sha384
            cache['SHA512'] = cache['sha512'] = _sha512.sha512
    except ImportError:
        pass  # no extension module, this hash is unsupported.

    constructor = cache.get(name)
    if constructor is not None:
        return constructor

    raise ValueError('unsupported hash type ' + name) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:30,代码来源:hashlib.py

示例11: _taa_digest

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def _taa_digest(text: str, version: str) -> str:
        return sha256('{}{}'.format(version, text).encode()).hexdigest() 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:4,代码来源:write_request_manager.py

示例12: replica_batch_digest

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def replica_batch_digest(reqs: List):
    return sha256(b''.join([r.digest.encode() for r in reqs])).hexdigest() 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:4,代码来源:replica_helper.py

示例13: view_change_digest

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def view_change_digest(msg: ViewChange) -> str:
    msg_as_dict = msg._asdict()
    # msg_as_dict['checkpoints'] = [cp.__dict__ for cp in msg_as_dict['checkpoints']]
    serialized = JsonSerializer().dumps(msg_as_dict)
    return sha256(serialized).hexdigest() 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:7,代码来源:view_change_storages.py

示例14: _get_msg_digest

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def _get_msg_digest(self, msg: NewView):
        msg_dict = msg._asdict()
        return sha256(JsonSerializer().dumps(msg_dict)).hexdigest() 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:5,代码来源:view_change_storages.py

示例15: generate_pp_digest

# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha256 [as 别名]
def generate_pp_digest(req_digests, original_view_no, pp_time):
        return sha256(serialize_msg_for_signing([original_view_no, pp_time, *req_digests])).hexdigest() 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:4,代码来源:ordering_service.py


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