當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。