From 80eb1f438bc512fa1bb3d043b485b9478c7e73dd Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 8 Dec 2022 14:08:07 +0100 Subject: [PATCH] implemented functioning logik to create passwords --- .gitignore | 1 + Readme.md | 16 +++++++++++ scripts/decrypt.py | 0 scripts/encrypt.py | 0 scripts/generate-hashtable.py | 50 ++++++++++++++++------------------- 5 files changed, 40 insertions(+), 27 deletions(-) create mode 100644 .gitignore create mode 100644 Readme.md create mode 100644 scripts/decrypt.py create mode 100644 scripts/encrypt.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..460aa0e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +./data \ No newline at end of file diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..dd422d5 --- /dev/null +++ b/Readme.md @@ -0,0 +1,16 @@ +# Splitted Secret +The purpose of this software is to splitt a secret over multiple people. Just if a defined amount of this people meet together they can encrypt the secret and have access to it. + +# Requirements to know +- Amount of People +- How much people need to reunite for decrypting + +# Requirements to implement +- Plattform independend +- easy to use + +## Further Information +- https://www.tutorialspoint.com/python/python_command_line_arguments.htm +- https://docs.python.org/3/library/argparse.html#module-argparse +- https://wiki.ubuntuusers.de/GoCryptFS/ +- https://pynative.com/python-generate-random-string/ \ No newline at end of file diff --git a/scripts/decrypt.py b/scripts/decrypt.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/encrypt.py b/scripts/encrypt.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/generate-hashtable.py b/scripts/generate-hashtable.py index a32085a..96961f4 100644 --- a/scripts/generate-hashtable.py +++ b/scripts/generate-hashtable.py @@ -2,9 +2,10 @@ import argparse import random import string + def getPassword(): characters = string.ascii_letters + string.digits - return ''.join(random.choice(characters) for i in range(int(128*quota_factor))).upper(); + return ''.join(random.choice(characters) for i in range(int(64*quota_factor))).upper(); if __name__ == '__main__': parser = argparse.ArgumentParser() @@ -14,35 +15,30 @@ if __name__ == '__main__': amount_of_secret_holders = args.amount_of_secret_holders; decryption_quota = args.decryption_quota; quota_factor=decryption_quota/100; - password_divisor=int(amount_of_secret_holders*quota_factor) - amount_of_partner_secrets=(amount_of_secret_holders * password_divisor) - required_passwords=amount_of_partner_secrets * ( amount_of_secret_holders -1) ; + password_group_members_amount=amount_of_secret_holders * quota_factor + amount_of_partner_secrets=(amount_of_secret_holders * password_group_members_amount) + #required_passwords=amount_of_partner_secrets * ( amount_of_secret_holders -1) ; + required_passwords=amount_of_partner_secrets * amount_of_secret_holders; print(quota_factor); print(amount_of_secret_holders); print(decryption_quota); print(required_passwords); - # generate splitted password matrix - secret_holders = {} - secret_holder_index = 0; + password_groups = {} + password_group_index = 0 + secret_holder_index = 0 + while password_group_index < required_passwords : + password_groups[password_group_index] = {}; + password_groups[password_group_index]['members'] = {} + password_groups[password_group_index]['password'] = '' + group_members_count = 0; + while group_members_count < password_group_members_amount : + if secret_holder_index == amount_of_secret_holders: + secret_holder_index = 0; + password_groups[password_group_index]['members'][secret_holder_index] = getPassword(); + password_groups[password_group_index]['password'] += ''.join(password_groups[password_group_index]['members'][secret_holder_index]) + secret_holder_index += 1; + group_members_count += 1; + password_group_index += 1; + print(password_groups); - while secret_holder_index < amount_of_secret_holders: - secret_holders[secret_holder_index] = {}; - partner_secret_holder_index = 0; - while partner_secret_holder_index < amount_of_secret_holders: - if partner_secret_holder_index != secret_holder_index : - secret_holders[secret_holder_index][partner_secret_holder_index] = {}; - secret_holders[secret_holder_index][partner_secret_holder_index][secret_holder_index] = {}; - index=0 - while index < password_divisor: - secret_holders[secret_holder_index][partner_secret_holder_index][secret_holder_index][index] = getPassword(); - index += 1; - partner_secret_holder_index += 1; - secret_holder_index += 1; - print(secret_holders); - - # generate passwords - passwords = [] - while secret_holder_index < amount_of_secret_holders: - - secret_holder_index += 1; \ No newline at end of file