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


Python _sha.new方法代码示例

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


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

示例1: test_none

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [as 别名]
def test_none(self):
        for testType in types:        
            self.assertRaises(TypeError, testType(b'abc').replace, b"new")
            self.assertRaises(TypeError, testType(b'abc').replace, b"new", 2)
            self.assertRaises(TypeError, testType(b'abc').center, 0, None)
            if str != bytes:
                self.assertRaises(TypeError, testType(b'abc').fromhex, None)
            self.assertRaises(TypeError, testType(b'abc').decode, 'ascii', None)
        
            for fn in ['find', 'index', 'rfind', 'count', 'startswith', 'endswith']:
                f = getattr(testType(b'abc'), fn)
                self.assertRaises(TypeError, f, None)
                self.assertRaises(TypeError, f, None, 0)
                self.assertRaises(TypeError, f, None, 0, 2)
        
            self.assertRaises(TypeError, testType(b'abc').replace, None, b'ef')
            self.assertRaises(TypeError, testType(b'abc').replace, None, b'ef', 1)
            self.assertRaises(TypeError, testType(b'abc').replace, b'abc', None)
            self.assertRaises(TypeError, testType(b'abc').replace, b'abc', None, 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:test_bytes.py

示例2: __get_builtin_constructor

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [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: __get_builtin_constructor

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [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

示例4: __get_builtin_constructor

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [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

示例5: __py_new

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [as 别名]
def __py_new(name, string=''):
    """new(name, string='') - Return a new hashing object using the named algorithm;
    optionally initialized with a string.
    """
    return __get_builtin_constructor(name)(string) 
开发者ID:glmcdona,项目名称:meddle,代码行数:7,代码来源:hashlib.py

示例6: __hash_new

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [as 别名]
def __hash_new(name, string=''):
    """new(name, string='') - Return a new hashing object using the named algorithm;
    optionally initialized with a string.
    """
    try:
        return _hashlib.new(name, string)
    except ValueError:
        # If the _hashlib module (OpenSSL) doesn't support the named
        # hash, try using our builtin implementations.
        # This allows for SHA224/256 and SHA384/512 support even though
        # the OpenSSL library prior to 0.9.8 doesn't provide them.
        return __get_builtin_constructor(name)(string) 
开发者ID:glmcdona,项目名称:meddle,代码行数:14,代码来源:hashlib.py

示例7: __get_builtin_constructor

# 需要导入模块: import _sha [as 别名]
# 或者: from _sha import new [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


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