本文整理汇总了Python中_sha256.sha224方法的典型用法代码示例。如果您正苦于以下问题:Python _sha256.sha224方法的具体用法?Python _sha256.sha224怎么用?Python _sha256.sha224使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_sha256
的用法示例。
在下文中一共展示了_sha256.sha224方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sha224_sanity
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [as 别名]
def test_sha224_sanity(self):
x = _sha256.sha224()
self.assertEqual(x.block_size, 64)
self.assertEqual(x.digest(),
'\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/')
self.assertEqual(x.digest_size, 28)
self.assertEqual(x.digest_size, x.digestsize)
self.assertEqual(x.hexdigest(),
'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
self.assertEqual(x.name, "SHA224")
x.update("abc")
self.assertEqual(x.hexdigest(),
'23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')
x_copy = x.copy()
self.assertTrue(x!=x_copy)
self.assertEqual(x.hexdigest(), x_copy.hexdigest())
示例2: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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)
示例3: test_sha224_sanity
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [as 别名]
def test_sha224_sanity(self):
x = _sha256.sha224()
self.assertEqual(x.block_size, 64)
self.assertEqual(x.digest(),
b'\xd1J\x02\x8c*:+\xc9Ga\x02\xbb(\x824\xc4\x15\xa2\xb0\x1f\x82\x8e\xa6*\xc5\xb3\xe4/')
self.assertEqual(x.digest_size, 28)
self.assertEqual(x.hexdigest(),
'd14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f')
self.assertEqual(x.name, "sha224")
x.update(b"abc")
self.assertEqual(x.hexdigest(),
'23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7')
x_copy = x.copy()
self.assertTrue(x!=x_copy)
self.assertEqual(x.hexdigest(), x_copy.hexdigest())
示例4: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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"
示例5: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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)
示例6: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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)
示例7: test_sanity
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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")
示例8: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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)
示例9: __get_builtin_constructor
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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
elif name in ('blake2b', 'blake2s'):
import _blake2
cache['blake2b'] = _blake2.blake2b
cache['blake2s'] = _blake2.blake2s
elif name in {'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512',
'shake_128', 'shake_256'}:
import _sha3
cache['sha3_224'] = _sha3.sha3_224
cache['sha3_256'] = _sha3.sha3_256
cache['sha3_384'] = _sha3.sha3_384
cache['sha3_512'] = _sha3.sha3_512
cache['shake_128'] = _sha3.shake_128
cache['shake_256'] = _sha3.shake_256
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)
示例10: test_sanity
# 需要导入模块: import _sha256 [as 别名]
# 或者: from _sha256 import sha224 [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))