Esempio n. 1
0
 def test_hash_collisions(self):
     keyvals = {}
     for b, d in itertools.product([True, False], [True, False]):
         for i in range(255):
             bstr = byte_to_bin(i)
             keyvals[bstr] = xor_chain(bstr, b, d)
         c = collections.Counter(keyvals.values())
         duplicates = [i for i in c if c[i]>1]
         self.assertEquals(0, len(duplicates),
                           ("duplicates found: {0}."
                           "# originals: {1}, # duplicates {2}").format(
                               duplicates,
                               len(duplicates),
                               len(keyvals.values())))
Esempio n. 2
0
 def test_xor_chain(self):
     for bytestr, noargs, keyT, len6, keyTlen3 in HashTest.test_strings:
         self.assertEquals(xor_chain(bytestr), noargs)
         self.assertEquals(xor_chain(bytestr, key=True), keyT)
         self.assertEquals(xor_chain(bytestr, length=6), len6)
         self.assertEquals(xor_chain(bytestr, key=True, length=3), keyTlen3)