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


Python _hashlib.new方法代码示例

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


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

示例1: __get_builtin_constructor

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

示例2: __hash_new

# 需要导入模块: import _hashlib [as 别名]
# 或者: from _hashlib import new [as 别名]
def __hash_new(name, data=b'', **kwargs):
    """new(name, data=b'') - Return a new hashing object using the named algorithm;
    optionally initialized with data (which must be bytes).
    """
    if name in {'blake2b', 'blake2s'}:
        # Prefer our blake2 implementation.
        # OpenSSL 1.1.0 comes with a limited implementation of blake2b/s.
        # It does neither support keyed blake2 nor advanced features like
        # salt, personal, tree hashing or SSE.
        return __get_builtin_constructor(name)(data, **kwargs)
    try:
        return _hashlib.new(name, data)
    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)(data) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:hashlib.py

示例3: __hash_new

# 需要导入模块: import _hashlib [as 别名]
# 或者: from _hashlib import new [as 别名]
def __hash_new(name, data=b'', **kwargs):
    """new(name, data=b'') - Return a new hashing object using the named algorithm;
    optionally initialized with data (which must be a bytes-like object).
    """
    if name in {'blake2b', 'blake2s'}:
        # Prefer our blake2 implementation.
        # OpenSSL 1.1.0 comes with a limited implementation of blake2b/s.
        # It does neither support keyed blake2 nor advanced features like
        # salt, personal, tree hashing or SSE.
        return __get_builtin_constructor(name)(data, **kwargs)
    try:
        return _hashlib.new(name, data)
    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)(data) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:20,代码来源:hashlib.py

示例4: __get_builtin_constructor

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

示例5: __get_builtin_constructor

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

示例6: __py_new

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

示例7: __hash_new

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

示例8: __get_builtin_constructor

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

示例9: __py_new

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

示例10: __hash_new

# 需要导入模块: import _hashlib [as 别名]
# 或者: from _hashlib import new [as 别名]
def __hash_new(name, data=b''):
    """new(name, data=b'') - Return a new hashing object using the named algorithm;
    optionally initialized with data (which must be bytes).
    """
    try:
        return _hashlib.new(name, data)
    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)(data) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:14,代码来源:hashlib.py


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