Added information to members

This commit is contained in:
Kevin Veen-Birkenbach 2022-12-09 22:37:29 +01:00
parent 09f494804f
commit 0831ab3448
3 changed files with 48 additions and 15 deletions

View File

@ -4,7 +4,20 @@ The purpose of this software is to splitt a secret over multiple people. Just if
# testing # testing
```bash ```bash
python scripts/main.py --mode cleanup && python scripts/main.py --mode cleanup &&
python scripts/main.py --amount 6 --quota 50 --mode encrypt --master-password "ewrwerwerew" && python scripts/main.py --amount 3 --quota 50 --mode encrypt --add-user-information --master-password "ewrwerwerew" << END_OF_INPUTS
alpha bravo
123123812908
asfdasd@asdskjd.de
street in straat
charlie delta
1888888
sadasfdasd@asdskjd.de
street in strutt
echo2 foxtrott
99999999
asfdasd@sdskjd.de
street in strasdlasöd
END_OF_INPUTS
python scripts/main.py --mode decrypt --master-password "ewrwerwerew" && python scripts/main.py --mode decrypt --master-password "ewrwerwerew" &&
python scripts/main.py --mode decrypt --user "1" python scripts/main.py --mode decrypt --user "1"
``` ```

View File

@ -15,6 +15,21 @@ class Encryption(AbstractSplittedSecret):
self.master_password = master_password self.master_password = master_password
self.quota_factor=self.decryption_quota/100 self.quota_factor=self.decryption_quota/100
self.group_members_amount=math.ceil(self.amount_of_secret_holders * self.quota_factor) self.group_members_amount=math.ceil(self.amount_of_secret_holders * self.quota_factor)
self.initializeUserData()
self.initializeGroupData()
def initializeUserData(self):
self.user_mapped_data = {}
user_count = 1
while user_count <= self.amount_of_secret_holders:
self.user_mapped_data[str(user_count)] = {"groups":{},"user_password":self.createPassword(64),"about":{}}
user_count += 1;
def initializeGroupData(self):
self.group_mapped_data = {}
def addInformationToUser(self,user_id,label,content):
self.user_mapped_data[user_id]['about'][label] = content;
def getStartnumber(self): def getStartnumber(self):
index = 0 index = 0
@ -42,19 +57,18 @@ class Encryption(AbstractSplittedSecret):
unvalid_sequenz = re.compile("(.)\\1+") unvalid_sequenz = re.compile("(.)\\1+")
return re.search(valid_numbers, password_group_index_str) and not re.search(unvalid_sequenz, password_group_index_str) return re.search(valid_numbers, password_group_index_str) and not re.search(unvalid_sequenz, password_group_index_str)
def createUserDataFrame(self): def compileContacts(self):
self.user_mapped_data = {} contacts = {}
user_count = 1 for user_id in self.user_mapped_data:
while user_count <= self.amount_of_secret_holders: contacts[user_id] = self.user_mapped_data[user_id]['about']
self.user_mapped_data[str(user_count)] = {"groups":{},"user_password":self.createPassword(64)} for user_id in self.user_mapped_data:
user_count += 1; self.user_mapped_data[user_id]['contacts'] = {}
for contact_id in contacts:
if contact_id != user_id:
self.user_mapped_data[user_id]['contacts'][contact_id] = contacts[contact_id]
def createGroupDataFrame(self): def compileData(self):
self.group_mapped_data = {} self.compileContacts()
def generateData(self):
self.createUserDataFrame()
self.createGroupDataFrame()
index = self.getStartnumber() index = self.getStartnumber()
while index < self.getEndnumber(): while index < self.getEndnumber():
password_group_index_str = ''.join(sorted(str(index))) password_group_index_str = ''.join(sorted(str(index)))
@ -89,7 +103,7 @@ class Encryption(AbstractSplittedSecret):
def encryptUserData(self): def encryptUserData(self):
for user_id in self.user_mapped_data: for user_id in self.user_mapped_data:
file_path=self.getUserFilePath(user_id,"encrypted") file_path=self.getUserFilePath(user_id,"encrypted")
data=self.user_mapped_data[user_id]['groups'] data=self.user_mapped_data[user_id]
password=self.user_mapped_data[user_id]['user_password'] password=self.user_mapped_data[user_id]['user_password']
self.encryptToJsonFile(data,file_path,password) self.encryptToJsonFile(data,file_path,password)

View File

@ -11,6 +11,7 @@ if __name__ == '__main__':
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',type=int, dest='user',choices=range(1,9),required=False) parser.add_argument('--user',type=int, dest='user',choices=range(1,9),required=False)
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()
mode = args.mode mode = args.mode
@ -56,6 +57,11 @@ if __name__ == '__main__':
else: else:
master_password = args.master_password master_password = args.master_password
encrypt = Encryption(args.amount_of_secret_holders, args.decryption_quota, master_password) encrypt = Encryption(args.amount_of_secret_holders, args.decryption_quota, master_password)
encrypt.generateData() if args.add_user_information is not None:
for user_id in encrypt.user_mapped_data:
for label in ['name','phone','email','address']:
print("Please enter attribut <<" + label + ">> for user <<" + user_id+ ">>:" )
encrypt.addInformationToUser(user_id, label, str(input()))
encrypt.compileData()
encrypt.encrypt() encrypt.encrypt()
exit() exit()