|
|
@ -127,7 +127,7 @@ def search(target, |
|
|
|
hashes_computed = 0 |
|
|
|
hashes_computed = 0 |
|
|
|
for secret in _all_bytestrings(): |
|
|
|
for secret in _all_bytestrings(): |
|
|
|
if stop_event.is_set(): |
|
|
|
if stop_event.is_set(): |
|
|
|
raise StopIteration() # pylint: disable=stop-iteration-return |
|
|
|
return |
|
|
|
candidate_hash = _get_hash(secret) |
|
|
|
candidate_hash = _get_hash(secret) |
|
|
|
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: |
|
|
@ -142,7 +142,7 @@ def search(target, |
|
|
|
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 |
|
|
|
return |
|
|
|
hashes_computed += 1 |
|
|
|
hashes_computed += 1 |
|
|
|
if hashes_computed == maximum_hashes: |
|
|
|
if hashes_computed == maximum_hashes: |
|
|
|
raise ResourceLimitExceededError() |
|
|
|
raise ResourceLimitExceededError() |
|
|
|