-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdecoding_test.py
More file actions
37 lines (25 loc) · 986 Bytes
/
decoding_test.py
File metadata and controls
37 lines (25 loc) · 986 Bytes
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
#!/usr/bin/python3
import subprocess
import base64
import string
import random
import sys
def get_random_string(length):
letters = string.ascii_lowercase + string.ascii_uppercase + string.digits
return "".join(random.choice(letters) for _ in range(length))
def main():
for i in range (1, 15):
for x in range(250):
print("\rtest input length: {} \t round: {}".format(i, x), end="")
sys.stdout.flush()
test_str = get_random_string(i)
assertion = base64.b64encode(test_str.encode("utf-8")).decode("utf-8")
result = subprocess.run(["./base", "-d", assertion], stdout=subprocess.PIPE)
str_result = result.stdout.decode("utf-8")
if str_result.strip() != test_str:
print("ERROR. expect: {} to be: {}. got: {}".format(assertion, test_str, str_result))
sys.exit(1)
print("\n\n\nall good!")
sys.exit(0)
if __name__ == "__main__":
main()