-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombinator.py
More file actions
40 lines (31 loc) · 1.42 KB
/
Copy pathCombinator.py
File metadata and controls
40 lines (31 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from itertools import product, permutations, combinations
class Combinator:
def __init__(self, target):
self.dataset = target
self.final_passwords = set()
# Individual elements
for tup in self.dataset:
self.final_passwords.update(tup)
# Intratuple combinations
for tup in self.dataset:
for r in range(2, len(tup) + 1):
for comb in combinations(tup, r):
for perm in permutations(comb):
self.final_passwords.add(''.join(perm))
# Full Cartesian product permutations
for combination in product(*self.dataset):
for permutation in permutations(combination):
self.final_passwords.add(''.join(permutation))
# 2-tuple Cartesian products
for i in range(len(self.dataset)):
for j in range(i + 1, len(self.dataset)):
for combination in product(self.dataset[i], self.dataset[j]):
self.final_passwords.add(''.join(combination))
# r-tuple dataset combinations (r >= 2)
for r in range(2, len(self.dataset) + 1):
for selected in combinations(self.dataset, r):
for prod in product(*selected):
for perm in permutations(prod):
self.final_passwords.add(''.join(perm))
def return_passwords(self):
return self.final_passwords