-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii2base64.py
31 lines (25 loc) · 1.09 KB
/
ascii2base64.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
30
31
import base64
import string
import tqdm
if __name__ == '__main__':
letters_digits = string.ascii_letters + string.digits + '='
input_letters = set(string.printable)
input_letters.remove('?')
input_letters.remove('>')
input_letters.remove('~')
input_letters = list(input_letters)
total = len(input_letters) ** 3
with tqdm.tqdm(total=total) as progress:
for a in input_letters:
for b in input_letters:
for c in input_letters:
line = f"{a}{b}{c}"
encoded = base64.b64encode(line.encode()).decode()
assert all(x in letters_digits for x in encoded), (line, encoded)
line = f"{a}{b}"
encoded = base64.b64encode(line.encode()).decode()
assert all(x in letters_digits for x in encoded), (line, encoded)
line = f"{a}"
encoded = base64.b64encode(line.encode()).decode()
assert all(x in letters_digits for x in encoded), (line, encoded)
progress.update()