I’m using python to generate combinations of a 74 character string and I’m using two combinations strings which are “0123456789abcdef” and “QQQQQQ33”. I want the QQQQQQ33 to be in brackets [] so that when it is used, it uses the full string instead of generating all combinations of the string with 0123456789abcdef.
Whenever I use the brackets, which is like the only way to make it print the strings in full instead of each combination, it doesn’t print anything to console. It just finishes the code with a checkmark in replit without printing anything.
The reason I’m using brackets is because I want the character mapping to be able to map the full string so that when I change my code to be other strings that are similar to QQQQQQ33 like AAAAAA9898, it can choose those characters first and map them first.
My code so far is:
import itertools
class MyIterator:
def __init__(self, full_iterable, hex_string, repeat, mapping_function=None):
self.full_iterable = full_iterable
self.hex_string = hex_string
self.repeat = repeat
self.mapping_function = mapping_function
if self.mapping_function:
self.full_iterable = self.mapping_function(self.full_iterable)
self.combinations = iter(self._generate_combinations())
self.current = next(self.combinations, None)
def _generate_combinations(self):
# Use full_iterable and hex_string in itertools.product
return itertools.product(self.full_iterable,self.hex_string, repeat=self.repeat)
def __iter__(self):
return self
def __next__(self):
if self.current is not None:
private_key = ''.join(self.current)
self.current = next(self.combinations, None)
return private_key
else:
raise StopIteration
def custom_mapping(hex_string):
# Define the custom mapping here
char_to_number = {
'0': 9,
'1': 1,
'2': 2,
'3': 3,
'4': 4,
'5': 5,
'6': 6,
'7': 7,
'8': 8,
'9': 0,
'a': 10,
'b': 11,
'c': 12,
'd': 13,
'e': 14,
'f': 15,
'A': 16,
'B': 17,
'C': 18,
'D': 19,
'E': 20,
'F': 21,
'0xF977814e90dA44bFA03b6295A0616a897441aceC': -2,
}
filtered_chars = [char for char in hex_string if char in char_to_number]
# Sort the filtered characters based on the custom mapping
sorted_chars = sorted(filtered_chars,
key=lambda char: char_to_number[char])
return ''.join(sorted_chars)
full_iterable = ["QQQQQQ33"]
hex_string = '0123456789abcdef'
repeat = 74
my_iterator = MyIterator(full_iterable,
hex_string,
repeat,
mapping_function=custom_mapping)
for private_key in my_iterator:
account = private_key
print(account + "n")
In full_iterable that is where I used the brackets to set it to [ ]. Right now, when I take out the brackets, it works and prints combinations but not the type of combinations I want. The combinations it prints without brackets is,
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303031
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303032
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303033
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303034
30303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303035
I don’t want it to generate the combinations like this. I want it to generate combinations with QQQQ… in there like this:
QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ331QQQQQQ332QQQQQQ33d
QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ331QQQQQQ332QQQQQQ33e
QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ330QQQQQQ331QQQQQQ332QQQQQQ33f
Keep in mind that the character mapping needs to also map
QQQQQQ33 while it’s being printed like this. I will be setting full_iterable to be numerous strings that are similar to that so I will need to use the mapping to map the full strings first and second and so on.