I wanna get all the characters combinations (same position, Upper and Lower case alternation only) from a determined word then get a hash from each one in a background process. My code (oficial, here is only a practical example) is working very well, creating threads for do the sha256 hash aside. In production i wanna populate an array/list with at least every 200 word combinations to start a threaded function and deal with these data.
My Example code:
from itertools import product
def get_sha256(x):
hash = hashlib.sha256(x().encode('utf-8')).hexdigest()
print(hash)
result = product("aA","bB","cC","dD","eE","fF","hH")
for permutation in result:
thread = get_sha256(''.join(permutation))
thread.start()
In the code above we are starting a new thread for each combination but in a large cartesian product it will crash even the biggest server. I need to feed a presized array/list then start the background thread after N values and not for each every value. Is possible to do something like "for permutation[100] in result:" to do the loop from 100 to 100 values?
Is desirable to control the threads defining some "max thread" and maybe a semaphore to stop the loop and wait for some thread to continue feeding the presized data blocks to the sha256 function.
Python 3.7