In between commit implementation of main data encryption

This commit is contained in:
2022-12-10 20:19:26 +01:00
parent a00550e0b6
commit 2b3e4932c2
11 changed files with 25 additions and 12 deletions

View File

@@ -4,7 +4,7 @@ class AbstractSplittedSecret(Cli):
USER_PASSWORD_LENGTHS = 64
OVERALL_PASSWORD_LENGTHS = 128
# At the moment the programm can used deal with one digit numbers.
# At the moment the programm can only deal with one digit numbers.
MAXIMUM_SECRET_HOLDERS = 9
MINIMUM_SECRET_HOLDERS = 2

View File

@@ -110,4 +110,8 @@ class Decryption(AbstractSplittedSecret):
def decryptAccumulatedFile(self):
input_file_path = self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_ENCRYPTED)
output_file_path = self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_DECRYPTED)
self.decryptFile(self.user_password, input_file_path, output_file_path)
self.decryptFile(self.user_password, input_file_path, output_file_path)
def decryptMainData(self):
# gpg --batch --passphrase "helloworld" -d data/encrypted/main_data.tar.gz.gpg | tar -xvzf -
pass

View File

@@ -100,19 +100,23 @@ class Encryption(AbstractSplittedSecret):
def encryptToJsonFile(self,data,file_path,password):
self.encryptStringToFile(json.dumps(data,ensure_ascii=False), file_path, password)
def encryptUserData(self):
def encryptUserFile(self):
for user_id in self.user_mapped_data:
file_path=self.getUserFilePath(user_id,AbstractSplittedSecret.TYPE_ENCRYPTED)
data=self.user_mapped_data[user_id]
password=self.user_mapped_data[user_id]['user_password']
self.encryptToJsonFile(data,file_path,password)
def encryptAccumulatedData(self):
def encryptAccumulatedFile(self):
file_path=self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_ENCRYPTED)
data={"user_mapped": self.user_mapped_data, "group_mapped": self.group_mapped_data}
self.encryptToJsonFile(data,file_path,self.master_password)
def encryptMainData(self):
self.executeCommand('tar -cvzf - data/decrypted/main_data | gpg -c --batch --passphrase "' + self.master_password +'" > data/encrypted/main_data.tar.gz.gpg');
pass
def encrypt(self):
self.encryptUserData()
self.encryptAccumulatedData()
self.encryptUserFile()
self.encryptAccumulatedFile()
self.encryptGroupFiles()