Moved functions from Paths to Encryption

This commit is contained in:
Kevin Veen-Birkenbach 2022-12-10 22:27:28 +01:00
parent baefc461fa
commit c85c108db5
3 changed files with 14 additions and 15 deletions

View File

@ -11,6 +11,10 @@ class Encryption():
USER_PASSWORD_LENGTHS = 64 USER_PASSWORD_LENGTHS = 64
OVERALL_PASSWORD_LENGTHS = 128 OVERALL_PASSWORD_LENGTHS = 128
# At the moment the programm can only deal with one digit numbers.
MAXIMUM_SECRET_HOLDERS = 9
MINIMUM_SECRET_HOLDERS = 2
def __init__(self, cli, paths, amount_of_secret_holders, decryption_quota,master_password): def __init__(self, cli, paths, amount_of_secret_holders, decryption_quota,master_password):
self.amount_of_secret_holders = amount_of_secret_holders self.amount_of_secret_holders = amount_of_secret_holders
self.decryption_quota = decryption_quota self.decryption_quota = decryption_quota
@ -35,6 +39,12 @@ class Encryption():
def addInformationToUser(self,user_id,label,content): def addInformationToUser(self,user_id,label,content):
self.user_mapped_data[user_id]['about'][label] = content; self.user_mapped_data[user_id]['about'][label] = content;
def getCoSecretHoldersRange():
return range(Encryption.MINIMUM_SECRET_HOLDERS,Encryption.MAXIMUM_SECRET_HOLDERS)
def getSecretHoldersRange():
return range(1,Encryption.MAXIMUM_SECRET_HOLDERS)
def getStartnumber(self): def getStartnumber(self):
index = 0 index = 0
start_number = '' start_number = ''

View File

@ -2,16 +2,6 @@ import os
class Paths(): class Paths():
# At the moment the programm can only deal with one digit numbers.
MAXIMUM_SECRET_HOLDERS = 9
MINIMUM_SECRET_HOLDERS = 2
def getCoSecretHoldersRange():
return range(Paths.MINIMUM_SECRET_HOLDERS,Paths.MAXIMUM_SECRET_HOLDERS)
def getSecretHoldersRange():
return range(1,Paths.MAXIMUM_SECRET_HOLDERS)
TYPE_ENCRYPTED="encrypted" TYPE_ENCRYPTED="encrypted"
TYPE_DECRYPTED="decrypted" TYPE_DECRYPTED="decrypted"

View File

@ -3,7 +3,6 @@ from classes.Encryption import Encryption
from classes.Cleanup import Cleanup from classes.Cleanup import Cleanup
from classes.Decryption import Decryption from classes.Decryption import Decryption
from getpass import getpass from getpass import getpass
from classes.Paths import Paths
import traceback import traceback
from classes.Cli import Cli from classes.Cli import Cli
from classes.Paths import Paths from classes.Paths import Paths
@ -34,11 +33,11 @@ try:
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--mode',type=str, dest='mode',required=True,choices=['cleanup','encrypt','decrypt']) parser.add_argument('--mode',type=str, dest='mode',required=True,choices=['cleanup','encrypt','decrypt'])
parser.add_argument('--file-types',type=str, dest='file_types',required=False,choices=[Paths.TYPE_DECRYPTED, Paths.TYPE_ENCRYPTED]) parser.add_argument('--file-types',type=str, dest='file_types',required=False,choices=[Paths.TYPE_DECRYPTED, Paths.TYPE_ENCRYPTED])
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=Paths.getCoSecretHoldersRange()) parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=Encryption.getCoSecretHoldersRange())
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False) 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) parser.add_argument('--master-password',type=str, dest='master_password',required=False)
parser.add_argument('--user-password',type=str, dest='user_password',required=False) parser.add_argument('--user-password',type=str, dest='user_password',required=False)
parser.add_argument('--user',type=int, dest='user',choices=Paths.getSecretHoldersRange(),required=False) parser.add_argument('--user',type=int, dest='user',choices=Encryption.getSecretHoldersRange(),required=False)
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction) parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction)
args = parser.parse_args() args = parser.parse_args()