Example #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())))
Example #2
0
done=False

# 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"
Example #3
0
# -------- Main Program Loop -----------

xoffset=width/2

while done==False:
	# Set the screen background
	screen.fill(black)
	# ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT

	# draw agar plate
	pygame.draw.circle(screen, white, [width/2, height/2], height/2)

	text = font.render("key", True, black)
	screen.blit(text, [xoffset,20])
	pygame.draw.line(screen,black,[xoffset-50,50],[xoffset+50,50],5)
	bstrlist = list(byte_to_bin(-1))

	for i in range(8):	
		yoffset = (i+2) * 45
		text = font.render(bstrlist[i],True, black)
		screen.blit(text, [xoffset-50,yoffset])
		pygame.draw.circle(screen, red if int(bstrlist[i]) else green, [xoffset, yoffset], 20)

	# ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT
	# Limit to 20 frames per second
	clock.tick(20)
	# Go ahead and update the screen with what we've drawn.
	pygame.display.flip()
# Be I	DLE friendly. If you forget this line, the program will 'hang'
# on exit.
pygame.quit ()
Example #4
0
done=False

# 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(-1)
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"