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