Python hashlib.name() Examples
The following are 30
code examples of hashlib.name().
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
hashlib
, or try the search function
.
Example #1
Source File: test_hashlib.py From ironpython3 with Apache License 2.0 | 6 votes |
def check(self, name, data, hexdigest): hexdigest = hexdigest.lower() 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: m = hash_object_constructor(data) computed = m.hexdigest() self.assertEqual( computed, hexdigest, "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), hexdigest)) computed = m.digest() digest = bytes.fromhex(hexdigest) self.assertEqual(computed, digest) self.assertEqual(len(digest), m.digest_size)
Example #2
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 #3
Source File: test_hashlib.py From CTFCrackTools 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 #4
Source File: test_hashlib.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def check(self, name, data, hexdigest): hexdigest = hexdigest.lower() 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: m = hash_object_constructor(data) computed = m.hexdigest() self.assertEqual( computed, hexdigest, "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), hexdigest)) computed = m.digest() digest = bytes.fromhex(hexdigest) self.assertEqual(computed, digest) self.assertEqual(len(digest), m.digest_size)
Example #5
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 #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 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 #8
Source File: test_hashlib.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def check(self, name, data, hexdigest): hexdigest = hexdigest.lower() 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: m = hash_object_constructor(data) computed = m.hexdigest() self.assertEqual( computed, hexdigest, "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), hexdigest)) computed = m.digest() digest = bytes.fromhex(hexdigest) self.assertEqual(computed, digest) self.assertEqual(len(digest), m.digest_size)
Example #9
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 #10
Source File: test_hashlib.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def check_blocksize_name(self, name, block_size=0, digest_size=0): constructors = self.constructors_to_test[name] for hash_object_constructor in constructors: m = hash_object_constructor() self.assertEqual(m.block_size, block_size) self.assertEqual(m.digest_size, digest_size) self.assertEqual(len(m.digest()), digest_size) self.assertEqual(m.name, name) # split for sha3_512 / _sha3.sha3 object self.assertIn(name.split("_")[0], repr(m))
Example #11
Source File: test_hashlib.py From ironpython3 with Apache License 2.0 | 5 votes |
def check_blocksize_name(self, name, block_size=0, digest_size=0): constructors = self.constructors_to_test[name] for hash_object_constructor in constructors: m = hash_object_constructor() self.assertEqual(m.block_size, block_size) self.assertEqual(m.digest_size, digest_size) self.assertEqual(len(m.digest()), digest_size) self.assertEqual(m.name, name) # split for sha3_512 / _sha3.sha3 object self.assertIn(name.split("_")[0], repr(m))
Example #12
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 #13
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 #14
Source File: test_hashlib.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_update(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: h = hash_object_constructor() h.update(data) computed = h.hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s using %s when updated returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #15
Source File: test_hashlib.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_name_attribute(self): for cons in self.hash_constructors: h = cons() self.assertIsInstance(h.name, str) self.assertIn(h.name, self.supported_hash_names) self.assertEqual(h.name, hashlib.new(h.name).name)
Example #16
Source File: test_hashlib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def check_update(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: h = hash_object_constructor() h.update(data) computed = h.hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s using %s when updated returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #17
Source File: test_hashlib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 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 #18
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 #19
Source File: test_hashlib.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def check_update(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: h = hash_object_constructor() h.update(data) computed = h.hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s using %s when updated returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #20
Source File: test_hashlib.py From CTFCrackTools with GNU General Public License v3.0 | 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 #21
Source File: test_hashlib.py From CTFCrackTools 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 #22
Source File: test_hashlib.py From ironpython2 with Apache License 2.0 | 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 #23
Source File: test_hashlib.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def check_blocksize_name(self, name, block_size=0, digest_size=0): constructors = self.constructors_to_test[name] for hash_object_constructor in constructors: m = hash_object_constructor() self.assertEqual(m.block_size, block_size) self.assertEqual(m.digest_size, digest_size) self.assertEqual(len(m.digest()), digest_size) self.assertEqual(m.name, name) # split for sha3_512 / _sha3.sha3 object self.assertIn(name.split("_")[0], repr(m))
Example #24
Source File: test_hashlib.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_name_attribute(self): for cons in self.hash_constructors: h = cons() self.assertIsInstance(h.name, str) self.assertIn(h.name, self.supported_hash_names) self.assertEqual(h.name, hashlib.new(h.name).name)
Example #25
Source File: test_hashlib.py From ironpython2 with Apache License 2.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 #26
Source File: test_hashlib.py From oss-ftp with MIT License | 5 votes |
def check_update(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: h = hash_object_constructor() h.update(data) computed = h.hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s using %s when updated returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #27
Source File: test_hashlib.py From ironpython2 with Apache License 2.0 | 5 votes |
def check_update(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: h = hash_object_constructor() h.update(data) computed = h.hexdigest() self.assertEqual( computed, digest, "Hash algorithm %s using %s when updated returned hexdigest" " %r for %d byte input data that should have hashed to %r." % (name, hash_object_constructor, computed, len(data), digest))
Example #28
Source File: test_hashlib.py From oss-ftp with MIT 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 #29
Source File: test_hashlib.py From oss-ftp with MIT 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 #30
Source File: test_hashlib.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_name_attribute(self): for cons in self.hash_constructors: h = cons() self.assertIsInstance(h.name, str) self.assertIn(h.name, self.supported_hash_names) self.assertEqual(h.name, hashlib.new(h.name).name)