Ejemplo n.º 1
0
class Fingerprint(object):

    def __init__(self, hash, key_type, hashtype):
        bishop = Bishop(76)
        self.atrium = Atrium(bishop, key_type, hashtype)
        moves = self.hash_to_moves(hash)
        lastmove = moves.pop()
        for move in moves:
            self.atrium.move(move)
        self.atrium.finalise(lastmove)


    def __str__(self):
        return str(self.atrium)

    def hash_to_moves(self, hash):
        moves =[]
        for word in hash:
            for pair in (3, 2, 1, 0):
                shift = pair*8
                byte = (word & (255 << shift)) >> shift
                for step in range(0, 8, 2):
                  mask = 3 << step
                  move = (byte & mask) >> step
                  moves.append(move)
        return moves
Ejemplo n.º 2
0
 def test_print_repeated_move(self):
     peter = Bishop(76);
     atrium = Atrium(peter, 'RSA 2048', 'MD5');
     atrium.move(0)
     atrium.move(3)
     atrium.move(0)
     atrium.move(3)
     atrium.move(0)
     atrium.move(3)
     dottyAtrium = open('atrium_multiple_move.txt', 'r').read()
     self.assertEqual(str(atrium), dottyAtrium)
Ejemplo n.º 3
0
 def test_print_repeated_move(self):
     peter = Bishop(76)
     atrium = Atrium(peter, 'RSA 2048', 'MD5')
     atrium.move(0)
     atrium.move(3)
     atrium.move(0)
     atrium.move(3)
     atrium.move(0)
     atrium.move(3)
     dottyAtrium = open('atrium_multiple_move.txt', 'r').read()
     self.assertEqual(str(atrium), dottyAtrium)