-
Notifications
You must be signed in to change notification settings - Fork 230
/
utils.py
29 lines (26 loc) · 913 Bytes
/
utils.py
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
from rich import print
from rich.console import Console
from rich.progress import Progress
console = Console()
progress = Progress()
class Pattern:
@staticmethod
def create(length: int=8192):
pattern = ''
parts = ['A', 'a', '0']
while len(pattern) != length:
pattern += parts[len(pattern) % 3]
if len(pattern) % 3 == 0:
parts[2] = chr(ord(parts[2]) + 1)
if parts[2] > '9':
parts[2] = '0'
parts[1] = chr(ord(parts[1]) + 1)
if parts[1] > 'z':
parts[1] = 'a'
parts[0] = chr(ord(parts[0]) + 1)
if parts[0] > 'Z':
parts[0] = 'A'
return pattern
@staticmethod
def offset(value: str, length: int=8192):
return Pattern.create(length).index(value)