def test_hasher(self): for bytestr, _, keyT, _, _, in HashTest.test_strings: x = hasher(bytestr, True, True, 8) i=0 result = "" while (x.step()): i+=1 result += str(int(x.output())) self.assertEquals(result, keyT) self.assertEquals("".join(x.hash), keyT) x.reset() i=0 result = "" while (x.step()): i+=1 result += str(int(x.output())) self.assertEquals(result, keyT, "Hasher failed after reset") self.assertEquals("".join(x.hash), keyT, "Hasher failed after reset") x.reset() for i in range(8): self.assertRaises(IncompleteHashError, lambda: x.hash) x.step()
# Used to manage how fast the screen updates clock=pygame.time.Clock() font = pygame.font.Font(None, 30) bigfont = pygame.font.Font(None, 40) smallfont = pygame.font.Font(None, 24) # center-align stuff xoffset=width/2 reset=True # reset the plate # create hasher object with random byte bstr = byte_to_bin() bstrlist = list(bstr) xo = xorhashobj.hasher(bstr, True, False, 8) # text ins_label = "Hit 'I' for instructions" ins_full_text ="The following commands are available:\n\ 1 - Set key to True\n\ 0 - Set key to False\n\ R - Reset the hash\n\ SPACE - Step through the hash one compuation at a time\n\ c - Toggle automatic mode (use SPACE to step)\n\ ESC - exit\n\ \n\ Press 'I' again to leave instructions" ##########################################################################
import xorhashobj x = xorhashobj.hasher("00000000", True, True, 8) i=0 while (x.step()): i+=1 output = x.output() print("Step " + str(i) + ": " + str(int(output))) x.reset() # now can start again i=0 while (x.step()): i+=1 output = x.output() print("Step " + str(i) + ": " + str(int(output)))