Python _md5.new() Examples
The following are 30
code examples of _md5.new().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
_md5
, or try the search function
.
Example #1
Source File: test_hashlib.py From BinderFilter with MIT License | 6 votes |
def test_large_update(self): aas = 'a' * 128 bees = 'b' * 127 cees = 'c' * 126 abcs = aas + bees + cees for name in self.supported_hash_names: m1 = hashlib.new(name) m1.update(aas) m1.update(bees) m1.update(cees) m2 = hashlib.new(name) m2.update(abcs) self.assertEqual(m1.digest(), m2.digest(), name+' update problem.') m3 = hashlib.new(name, abcs) self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
Example #2
Source File: hashlib.py From Computable with MIT License | 6 votes |
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)
Example #3
Source File: test_hashlib.py From oss-ftp with MIT License | 6 votes |
def test_large_update(self): aas = 'a' * 128 bees = 'b' * 127 cees = 'c' * 126 abcs = aas + bees + cees for name in self.supported_hash_names: m1 = hashlib.new(name) m1.update(aas) m1.update(bees) m1.update(cees) m2 = hashlib.new(name) m2.update(abcs) self.assertEqual(m1.digest(), m2.digest(), name+' update problem.') m3 = hashlib.new(name, abcs) self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
Example #4
Source File: hashlib.py From medicare-demo with Apache License 2.0 | 6 votes |
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"
Example #5
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_large_update(self): aas = 'a' * 128 bees = 'b' * 127 cees = 'c' * 126 abcs = aas + bees + cees for name in self.supported_hash_names: m1 = hashlib.new(name) m1.update(aas) m1.update(bees) m1.update(cees) m2 = hashlib.new(name) m2.update(abcs) self.assertEqual(m1.digest(), m2.digest(), name+' update problem.') m3 = hashlib.new(name, abcs) self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
Example #6
Source File: test_hashlib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def test_large_update(self): aas = 'a' * 128 bees = 'b' * 127 cees = 'c' * 126 abcs = aas + bees + cees for name in self.supported_hash_names: m1 = hashlib.new(name) m1.update(aas) m1.update(bees) m1.update(cees) m2 = hashlib.new(name) m2.update(abcs) self.assertEqual(m1.digest(), m2.digest(), name+' update problem.') m3 = hashlib.new(name, abcs) self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
Example #7
Source File: test_hashlib.py From ironpython2 with Apache License 2.0 | 6 votes |
def test_large_update(self): aas = 'a' * 128 bees = 'b' * 127 cees = 'c' * 126 abcs = aas + bees + cees for name in self.supported_hash_names: m1 = hashlib.new(name) m1.update(aas) m1.update(bees) m1.update(cees) m2 = hashlib.new(name) m2.update(abcs) self.assertEqual(m1.digest(), m2.digest(), name+' update problem.') m3 = hashlib.new(name, abcs) self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
Example #8
Source File: hashlib.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #9
Source File: test_hashlib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def check(self, name, data, digest): constructors = self.constructors_to_test[name] # 2 is for hashlib.name(...) and hashlib.new(name, ...) self.assertGreaterEqual(len(constructors), 2) for hash_object_constructor in constructors: computed = hash_object_constructor(data).hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s constructed using %s returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #10
Source File: hashlib.py From PokemonGo-DesktopMap with MIT License | 5 votes |
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)
Example #11
Source File: test_hashlib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def check_unicode(self, algorithm_name): # Unicode objects are not allowed as input. expected = hashlib.new(algorithm_name, str(u'spam')).hexdigest() self.check(algorithm_name, u'spam', expected)
Example #12
Source File: hashlib.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: hashlib.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: hashlib.py From RevitBatchProcessor with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: hashlib.py From PokemonGo-DesktopMap with MIT License | 5 votes |
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)
Example #16
Source File: hashlib.py From unity-python with MIT License | 5 votes |
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)
Example #17
Source File: hashlib.py From unity-python with MIT License | 5 votes |
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)
Example #18
Source File: hashlib.py From medicare-demo with Apache License 2.0 | 5 votes |
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)
Example #19
Source File: hashlib.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #20
Source File: hashlib.py From Splunking-Crime with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #21
Source File: hashlib.py From datafari with Apache License 2.0 | 5 votes |
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)
Example #22
Source File: hashlib.py From datafari with Apache License 2.0 | 5 votes |
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)
Example #23
Source File: hashlib.py From datafari with Apache License 2.0 | 5 votes |
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)
Example #24
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_unicode(self, algorithm_name): # Unicode objects are not allowed as input. expected = hashlib.new(algorithm_name, str(u'spam')).hexdigest() self.check(algorithm_name, u'spam', expected)
Example #25
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check(self, name, data, digest): constructors = self.constructors_to_test[name] # 2 is for hashlib.name(...) and hashlib.new(name, ...) self.assertGreaterEqual(len(constructors), 2) for hash_object_constructor in constructors: computed = hash_object_constructor(data).hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s constructed using %s returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #26
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_hexdigest(self): for name in self.supported_hash_names: h = hashlib.new(name) self.assertTrue(hexstr(h.digest()) == h.hexdigest())
Example #27
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_unknown_hash(self): self.assertRaises(ValueError, hashlib.new, 'spam spam spam spam spam') self.assertRaises(TypeError, hashlib.new, 1)
Example #28
Source File: hashlib.py From pmatic with GNU General Public License v2.0 | 5 votes |
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)
Example #29
Source File: hashlib.py From pmatic with GNU General Public License v2.0 | 5 votes |
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)
Example #30
Source File: hashlib.py From meddle with MIT License | 5 votes |
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)