Exemplo n.º 1
0
    def __init__(self, poly, size = DEFAULT_RABIN_FINGERPRINT_SIZE):
        self._size = size
        self._buff = bytearray(size)
        self._shift = 0
        self._fingerprint = 0
        self._buffpos = -1
        self._calculate_lookup_table(poly)
        sizeshift = 1
        for i in range(1, size):
            sizeshift = self._add_byte(sizeshift, 0)

        self._u = [0] + [ polymath.mmult(i, sizeshift, poly) for i in range(1, 256) ]
Exemplo n.º 2
0
 def _calculate_lookup_table(self, poly):
     xshift = poly.bit_length() - 1
     self._shift = xshift - 8
     t1 = polymath.mod(1 << xshift, poly)
     self._t = [ polymath.mmult(j, t1, poly) | j << xshift for j in range(0, 256) ]