-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_menu.py
63 lines (47 loc) · 2.5 KB
/
cli_menu.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import getpass
from sys import exit
from argparse import Namespace
def print_logo():
print(' ._______ .______ .______ ._____.___ .______ .______ ._______ .______ ____ ____._______ _____._._______ ')
print(' : __ / : \\ :_ _ \\ : |: \\ : \\ :_. ___\\: __ \\ \\ \\_/ /: ____ |\\__ _:|: .___ \\ ')
print(' | |> \\ | . || | || \\ / || . || | | : |/\\ | \\____| \\___ ___/ | : | | :|| : | | ')
print(' | |> \\| : || . | || |\\/ || : || | | | / \\| : \\ | | | |___| | || : | ')
print(' |_______/|___| ||. ____/ |___| | ||___| ||___| | |. _____/| |___\\ |___| |___| | | \\_. ___/ ')
print(' |___| :/ |___| |___| |___| :/ |___| |___| :/ ')
print(' : : : ')
print(' ')
print(' ')
def passphrase_input():
passphrase = getpass.getpass("Your password: ")
if len(passphrase) == 0:
passphrase = None
return passphrase
def encrypt_menu() -> Namespace:
infile = input("File container: ")
outfile = input("Output file: ")
files_input = input("Files to encrypt or folder (separate with space): ")
files = files_input.split() if files_input else []
decrypt = False
passphrase = passphrase_input()
return Namespace(infile=infile, outfile=outfile, files=files, decrypt=decrypt, passphrase=passphrase)
def decrypt_menu() -> Namespace:
infile = input("File to decrypt: ")
decrypt = True
passphrase = passphrase_input()
return Namespace(infile=infile, decrypt=decrypt, passphrase=passphrase)
def main_menu() -> Namespace:
print_logo()
while True:
print("[1] Encrypt")
print("[2] Decrypt")
print("[0] Exit")
action = int(input())
if action == 1:
return encrypt_menu()
elif action == 2:
return decrypt_menu()
elif action == 0:
exit(0)
else:
print("Invalid option, try again")
print("\n\n")