mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2025-09-09 19:57:17 +02:00
Implemented destructor for main
This commit is contained in:
@@ -8,6 +8,9 @@ class AbstractSplittedSecret(Cli):
|
||||
MAXIMUM_SECRET_HOLDERS = 9
|
||||
MINIMUM_SECRET_HOLDERS = 2
|
||||
|
||||
TYPE_ENCRYPTED="encrypted"
|
||||
TYPE_DECRYPTED="decrypted"
|
||||
|
||||
def __init__(self):
|
||||
super(Cli, self).__init__()
|
||||
self.data_folder = "data/"
|
||||
@@ -28,7 +31,7 @@ class AbstractSplittedSecret(Cli):
|
||||
return self.getFolderPath(folder_type) + "user_files/"
|
||||
|
||||
def getFileExtension(self,file_type):
|
||||
if file_type == "encrypted":
|
||||
if file_type == AbstractSplittedSecret.TYPE_ENCRYPTED:
|
||||
return '.gpg'
|
||||
return ''
|
||||
|
||||
|
@@ -1,6 +1,5 @@
|
||||
from .AbstractSplittedSecret import AbstractSplittedSecret
|
||||
class Cleanup(AbstractSplittedSecret):
|
||||
|
||||
def __init__(self):
|
||||
super(Cleanup, self).__init__()
|
||||
|
||||
@@ -17,21 +16,17 @@ class Cleanup(AbstractSplittedSecret):
|
||||
except:
|
||||
pass
|
||||
|
||||
def deleteAllFiles(self,file_type):
|
||||
def cleanupFiles(self,file_type):
|
||||
for folder_path in self.getAllFilePaths(file_type):
|
||||
self.deleteAllFilesInFolder(folder_path)
|
||||
|
||||
def deleteAllEncryptedFiles(self):
|
||||
for folder_path in self.encrypted_files_folders:
|
||||
self.deleteAllFilesInFolder(folder_path)
|
||||
|
||||
def cleanupForUser(self,user):
|
||||
try:
|
||||
self.executeCommand('find "' + self.getFolderPath("encrypted") + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
self.executeCommand('find "' + self.getFolderPath(AbstractSplittedSecret.TYPE_ENCRYPTED) + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
except:
|
||||
pass
|
||||
self.deleteAllFiles("decrypted")
|
||||
self.cleanupFiles(AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||
|
||||
def deleteAll(self):
|
||||
self.deleteAllFiles("encrypted")
|
||||
self.deleteAllFiles("decrypted")
|
||||
self.cleanupFiles(AbstractSplittedSecret.TYPE_ENCRYPTED)
|
||||
self.cleanupFiles(AbstractSplittedSecret.TYPE_DECRYPTED)
|
@@ -9,7 +9,7 @@ class Decryption(AbstractSplittedSecret):
|
||||
|
||||
def initializeUser(self,user_id):
|
||||
self.user_id=str(user_id)
|
||||
self.user_file_decrypted_path = self.getUserFilePath(self.user_id,"decrypted")
|
||||
self.user_file_decrypted_path = self.getUserFilePath(self.user_id,AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||
|
||||
def initializeUserDataDecryption(self):
|
||||
self.decryptUserFile()
|
||||
@@ -59,10 +59,10 @@ class Decryption(AbstractSplittedSecret):
|
||||
self.executeCommand('gpg --batch --passphrase "'+ password + '" -o "' + output_file_path +'" "'+ input_file_path+'"')
|
||||
|
||||
def decryptUserFile(self):
|
||||
input_file_path = self.getUserFilePath(self.user_id,"encrypted")
|
||||
input_file_path = self.getUserFilePath(self.user_id,AbstractSplittedSecret.TYPE_ENCRYPTED)
|
||||
self.decryptFile(self.user_password, input_file_path, self.user_file_decrypted_path)
|
||||
|
||||
def decryptAccumulatedFile(self):
|
||||
input_file_path = self.getAccumulatedFilePath("encrypted")
|
||||
output_file_path = self.getAccumulatedFilePath("decrypted")
|
||||
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)
|
@@ -94,7 +94,7 @@ class Encryption(AbstractSplittedSecret):
|
||||
|
||||
def encryptGroupFiles(self):
|
||||
for password_group_index_int in self.group_mapped_data:
|
||||
encrypted_group_password_file_path = self.getGroupFilePath(password_group_index_int,"encrypted")
|
||||
encrypted_group_password_file_path = self.getGroupFilePath(password_group_index_int,AbstractSplittedSecret.TYPE_ENCRYPTED)
|
||||
self.encryptStringToFile(self.master_password,encrypted_group_password_file_path,self.group_mapped_data[password_group_index_int]['password'])
|
||||
|
||||
def encryptToJsonFile(self,data,file_path,password):
|
||||
@@ -102,13 +102,13 @@ class Encryption(AbstractSplittedSecret):
|
||||
|
||||
def encryptUserData(self):
|
||||
for user_id in self.user_mapped_data:
|
||||
file_path=self.getUserFilePath(user_id,"encrypted")
|
||||
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):
|
||||
file_path=self.getAccumulatedFilePath("encrypted")
|
||||
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)
|
||||
|
||||
|
Reference in New Issue
Block a user