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 sign_transaction (self,transact): hasher = SHA3_256.new() if len(self.current_transactions) > 0: transact_string = self.current_transactions[-1].hash . self.current_transactions.indexof(self.current_transactions[-1]) . hasher.update(transact) print(hasher.hexdigest())