|
|
|
@ -134,16 +134,14 @@ def search(target, |
|
|
|
|
distance = _get_substring_hamming_distance(candidate_hash, target) |
|
|
|
|
if interesting_hamming_distance is not None and distance <= interesting_hamming_distance: |
|
|
|
|
# Surface interesting candidates, but don't stop. |
|
|
|
|
yield protos.HashNameResponse( |
|
|
|
|
secret=base64.b64encode(secret), |
|
|
|
|
hashed_name=candidate_hash, |
|
|
|
|
hamming_distance=distance) |
|
|
|
|
yield protos.HashNameResponse(secret=base64.b64encode(secret), |
|
|
|
|
hashed_name=candidate_hash, |
|
|
|
|
hamming_distance=distance) |
|
|
|
|
elif distance <= ideal_distance: |
|
|
|
|
# Yield ideal candidate and end the stream. |
|
|
|
|
yield protos.HashNameResponse( |
|
|
|
|
secret=base64.b64encode(secret), |
|
|
|
|
hashed_name=candidate_hash, |
|
|
|
|
hamming_distance=distance) |
|
|
|
|
yield protos.HashNameResponse(secret=base64.b64encode(secret), |
|
|
|
|
hashed_name=candidate_hash, |
|
|
|
|
hamming_distance=distance) |
|
|
|
|
raise StopIteration() # pylint: disable=stop-iteration-return |
|
|
|
|
hashes_computed += 1 |
|
|
|
|
if hashes_computed == maximum_hashes: |
|
|
|
|