Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_hash128():
assert mmh3.hash128('foo') == 168394135621993849475852668931176482145
assert mmh3.hash128('foo', 42) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = False) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = True) == -124315475380607080215185174712879655950
# TODO
def test_hash128():
assert mmh3.hash128('foo') == 168394135621993849475852668931176482145
assert mmh3.hash128('foo', 42) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = False) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = True) == -124315475380607080215185174712879655950
# TODO
def test_hash128():
assert mmh3.hash128('foo') == 168394135621993849475852668931176482145
assert mmh3.hash128('foo', 42) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = False) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = True) == -124315475380607080215185174712879655950
# TODO
def test_hash128():
assert mmh3.hash128('foo') == 168394135621993849475852668931176482145
assert mmh3.hash128('foo', 42) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = False) == 215966891540331383248189432718888555506
assert mmh3.hash128('foo', 42, signed = True) == -124315475380607080215185174712879655950
# TODO
def hash_string(s):
return "html2latex_{version}_{mmh3_hash}_{hmac_of_sha512_hash}".format(
version=VERSION,
mmh3_hash=mmh3.hash128(s),
hmac_of_sha512_hash=hmac.new(hashlib.sha512(s).hexdigest()).hexdigest(),
)
def _hash(self, item):
bloom = 0
for salt in self.salts:
bloom |= (1L << (mmh3.hash128(salt + str(item)) % self.m))
return bloom
def genPrimaryKey64(data):
return "%x" % (mmh3.hash128(data) & 0xFFFFFFFFFFFFFFFF)
except zlib.error as e:
logger.error('BROWSER %i: Received zlib error when trying to decompress gzipped javascript: %s' % (browser_params['crawl_id'],str(e)))
return
elif 'deflate' in content_encoding[0].lower():
try:
script = zlib.decompress(msg.response.content, -zlib.MAX_WBITS)
except zlib.error as e:
logger.error('BROWSER %i: Received zlib error when trying to decompress deflated javascript: %s' % (browser_params['crawl_id'],str(e)))
return
else:
logger.error('BROWSER %i: Received Content-Encoding %s. Not supported by Firefox, skipping archive.' % (browser_params['crawl_id'], str(content_encoding)))
return
script = encode_to_unicode(script)
# Hash script for deduplication on disk
hasher = mmh3.hash128
script_hash = str(hasher(script.encode('utf-8')) >> 64)
ldb_socket.send((script, script_hash))
return script_hash