split-secret/scripts/main.py

44 lines
1.7 KiB
Python
Raw Normal View History

2022-12-09 12:03:45 +01:00
import argparse
2022-12-09 20:13:48 +01:00
from classes.Encryption import Encryption
from classes.Cleanup import Cleanup
2022-12-09 20:13:48 +01:00
from classes.Decryption import Decryption
from getpass import getpass
2022-12-09 12:03:45 +01:00
if __name__ == '__main__':
parser = argparse.ArgumentParser()
2022-12-09 20:10:12 +01:00
parser.add_argument('--mode',type=str, dest='mode',required=True,choices=['cleanup','generate','decrypt'])
2022-12-09 13:22:57 +01:00
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=range(1,9))
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
parser.add_argument('--master-password',type=str, dest='master_password',required=False)
2022-12-09 18:16:31 +01:00
parser.add_argument('--user',type=int, dest='user',choices=range(1,9),required=False)
2022-12-09 12:03:45 +01:00
args = parser.parse_args()
if args.mode == 'cleanup':
cleanup = Cleanup()
2022-12-09 18:16:31 +01:00
if args.user is None:
cleanup.deleteAll()
exit()
cleanup.cleanupForUser(args.user)
2022-12-09 20:10:12 +01:00
exit()
2022-12-09 20:10:12 +01:00
if args.mode == 'decrypt':
2022-12-09 20:13:48 +01:00
decrypt = Decryption()
2022-12-09 20:10:12 +01:00
if args.user is None:
print("Please type in the user number:")
decrypt.setUser(int(input()))
else:
decrypt.setUser(args.user)
print("Please enter the master password:")
user_password = getpass()
exit()
if args.mode == 'generate':
if args.master_password is None:
print("Please enter the master password:")
master_password = getpass()
else:
master_password = args.master_password
2022-12-09 20:13:48 +01:00
generate = Encryption(args.amount_of_secret_holders, args.decryption_quota,master_password)
generate.generate()
exit()