mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2025-09-09 19:57:17 +02:00
Finished full encryption implementation
This commit is contained in:
@@ -21,14 +21,20 @@ class AbstractSplittedSecret(Cli):
|
||||
def getSecretHoldersRange():
|
||||
return range(1,AbstractSplittedSecret.MAXIMUM_SECRET_HOLDERS)
|
||||
|
||||
def getFolderPath(self,folder_type):
|
||||
def getDataFolderPath(self,folder_type):
|
||||
return self.data_folder + folder_type + "/"
|
||||
|
||||
def getGroupFilesFolderPath(self,folder_type):
|
||||
return self.getFolderPath(folder_type) + "group_files/"
|
||||
return self.getDataFolderPath(folder_type) + "group_files/"
|
||||
|
||||
def getUserFilesFolderPath(self,folder_type):
|
||||
return self.getFolderPath(folder_type) + "user_files/"
|
||||
return self.getDataFolderPath(folder_type) + "user_files/"
|
||||
|
||||
def getEncryptedMainDataFile(self):
|
||||
return self.getDataFolderPath(AbstractSplittedSecret.TYPE_ENCRYPTED) + "main_data.tar.gz.gpg"
|
||||
|
||||
def getDecryptedMainDataStandartFolder(self):
|
||||
return self.getDataFolderPath(AbstractSplittedSecret.TYPE_DECRYPTED) + "main_data/"
|
||||
|
||||
def getFileExtension(self,file_type):
|
||||
if file_type == AbstractSplittedSecret.TYPE_ENCRYPTED:
|
||||
@@ -42,4 +48,4 @@ class AbstractSplittedSecret(Cli):
|
||||
return self.getGroupFilesFolderPath(file_type) + str(group_id) + '.txt' + self.getFileExtension(file_type);
|
||||
|
||||
def getAccumulatedFilePath(self,file_type):
|
||||
return self.getFolderPath(file_type) + 'accumulated.json' + self.getFileExtension(file_type);
|
||||
return self.getDataFolderPath(file_type) + 'accumulated.json' + self.getFileExtension(file_type);
|
@@ -4,17 +4,20 @@ class Cleanup(AbstractSplittedSecret):
|
||||
super(Cleanup, self).__init__()
|
||||
|
||||
def getAllFilePaths(self,file_type):
|
||||
return [
|
||||
all_file_paths = [
|
||||
self.getGroupFilesFolderPath(file_type),
|
||||
self.getUserFilesFolderPath(file_type),
|
||||
self.getAccumulatedFilePath(file_type)
|
||||
]
|
||||
if file_type == AbstractSplittedSecret.TYPE_DECRYPTED:
|
||||
all_file_paths.append(self.getDecryptedMainDataStandartFolder())
|
||||
return all_file_paths
|
||||
|
||||
def deleteAllFilesInFolder(self,folder_path):
|
||||
try:
|
||||
self.executeCommand('rm -v ' + folder_path + '*')
|
||||
except:
|
||||
pass
|
||||
self.executeCommand('rm -r ' + folder_path + '*')
|
||||
except Exception as error:
|
||||
print(error)
|
||||
|
||||
def cleanupFiles(self,file_type):
|
||||
for folder_path in self.getAllFilePaths(file_type):
|
||||
@@ -22,9 +25,9 @@ class Cleanup(AbstractSplittedSecret):
|
||||
|
||||
def cleanupForUser(self,user):
|
||||
try:
|
||||
self.executeCommand('find "' + self.getFolderPath(AbstractSplittedSecret.TYPE_ENCRYPTED) + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
except:
|
||||
pass
|
||||
self.executeCommand('find "' + self.getDataFolderPath(AbstractSplittedSecret.TYPE_ENCRYPTED) + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
except Exception as error:
|
||||
print(error)
|
||||
self.cleanupFiles(AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||
|
||||
def deleteAll(self):
|
||||
|
@@ -22,7 +22,7 @@ class Decryption(AbstractSplittedSecret):
|
||||
self.group_name = self.getDecryptersGroupName()
|
||||
self.encrypted_group_file_path = self.getGroupFilePath(self.group_name, AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||
self.decryptGroupFile()
|
||||
self.master_password = self.loadTxtFile(self.encrypted_group_file_path)
|
||||
self.master_password = self.loadTxtFile(self.encrypted_group_file_path).strip()
|
||||
|
||||
def initializeNeededDecryptersAmount(self):
|
||||
self.needed_decrypters_amount = len(str(list(self.user_data['groups'].keys())[0]))
|
||||
@@ -113,5 +113,4 @@ class Decryption(AbstractSplittedSecret):
|
||||
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
|
||||
self.executeCommand('gpg --batch --passphrase "' + self.getMasterPassword() + '" -d "' + self.getEncryptedMainDataFile() + '" | tar -xvzf - "' + self.getDecryptedMainDataStandartFolder() + '"')
|
@@ -113,10 +113,10 @@ class Encryption(AbstractSplittedSecret):
|
||||
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
|
||||
self.executeCommand('tar -cvzf - "' + self.getDecryptedMainDataStandartFolder() + '" | gpg -c --batch --passphrase "' + self.master_password +'" > "' + self.getEncryptedMainDataFile() + '"');
|
||||
|
||||
def encrypt(self):
|
||||
def encryptAll(self):
|
||||
self.encryptUserFile()
|
||||
self.encryptAccumulatedFile()
|
||||
self.encryptGroupFiles()
|
||||
self.encryptMainData()
|
||||
|
Reference in New Issue
Block a user