def test_update_after_digest(self): msg = b("rrrrttt") # Normally, update() cannot be done after digest() h = SHA3.new(data=msg[:4]) dig1 = h.digest() self.assertRaises(TypeError, h.update, msg[4:]) dig2 = SHA3.new(data=msg).digest() # With the proper flag, it is allowed h = SHA3.new(data=msg[:4], update_after_digest=True) self.assertEquals(h.digest(), dig1) # ... and the subsequent digest applies to the entire message # up to that point h.update(msg[4:]) self.assertEquals(h.digest(), dig2)
def test_update_after_digest(self): msg=b("rrrrttt") # Normally, update() cannot be done after digest() h = SHA3.new(data=msg[:4]) dig1 = h.digest() self.assertRaises(TypeError, h.update, msg[4:]) dig2 = SHA3.new(data=msg).digest() # With the proper flag, it is allowed h = SHA3.new(data=msg[:4], update_after_digest=True) self.assertEquals(h.digest(), dig1) # ... and the subsequent digest applies to the entire message # up to that point h.update(msg[4:]) self.assertEquals(h.digest(), dig2)
h = SHA512.new() for i in range(0, 50): for dato in datos: timeI = time() h.update(bytearray.fromhex(dato)) timeF = time() listaTmpoSHA512.append(timeF - timeI) #print(h.hexdigest()) #--------------------------- SHA-3 384 ----------------------------------------- #HASH #print("\n *****************SHA3-384********************* ") datos = leeArchivoSHA("SHA3_384ShortMsg.rsp") + leeArchivoSHA( "SHA3_384LongMsg.rsp") listaTmpoSHA3_384 = [] h = SHA3_384.new() for i in range(0, 50): for dato in datos: timeI = time() h.update(bytearray.fromhex(dato)) timeF = time() listaTmpoSHA3_384.append(timeF - timeI) #print(h.hexdigest()) #--------------------------- SHA-3 512 ----------------------------------------- #HASH #print("\n *****************SHA3-512********************* ") datos = leeArchivoSHA("SHA3_512ShortMsg.rsp") + leeArchivoSHA( "SHA3_512LongMsg.rsp") listaTmpoSHA3_512 = [] h = SHA3_512.new()