mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2024-11-25 03:31:03 +01:00
Implemented decryption of user file
This commit is contained in:
parent
10689122c0
commit
b3c31c0013
@ -17,8 +17,8 @@ class AbstractSplittedSecret(Cli):
|
||||
|
||||
def getFileExtension(self,file_type):
|
||||
if file_type == "encrypted":
|
||||
return ''
|
||||
return '.gpg'
|
||||
return '.gpg'
|
||||
return ''
|
||||
|
||||
def getUserFilePath(self,user_id,file_type):
|
||||
return self.getUserFilesFolderPath(file_type)+user_id+'.json' + self.getFileExtension(file_type);
|
||||
|
@ -4,7 +4,7 @@ class Decryption(AbstractSplittedSecret):
|
||||
def __init__(self):
|
||||
self.user_id='0';
|
||||
self.user_password=''
|
||||
pass
|
||||
super(Decryption, self).__init__()
|
||||
|
||||
def setUserId(self,user_id):
|
||||
self.user_id=str(user_id)
|
||||
@ -12,12 +12,13 @@ class Decryption(AbstractSplittedSecret):
|
||||
def setUserPassword(self,user_password):
|
||||
self.user_password = str(user_password)
|
||||
|
||||
def decryptFile(self,password,input_file_path):
|
||||
self.executeCommand('gpg --batch --passphrase "'+ password + '" '+ file_path)
|
||||
def decryptFile(self,password,input_file_path,output_file_path):
|
||||
self.executeCommand('gpg --batch --passphrase "'+ password + '" -o "' + output_file_path +'" "'+ input_file_path+'"')
|
||||
print(self.getCommandString())
|
||||
print(self.getOutputString())
|
||||
|
||||
def decryptUserFile(self):
|
||||
input_file_path = self.getUserFilePath(self.user_id)
|
||||
self.decryptFile(self.user_password, file_path)
|
||||
input_file_path = self.getUserFilePath(self.user_id,"encrypted")
|
||||
output_file_path = self.getUserFilePath(self.user_id,"decrypted")
|
||||
self.decryptFile(self.user_password, input_file_path,output_file_path)
|
||||
|
@ -25,11 +25,13 @@ if __name__ == '__main__':
|
||||
decrypt = Decryption()
|
||||
if args.user is None:
|
||||
print("Please type in the user number:")
|
||||
decrypt.setUser(int(input()))
|
||||
decrypt.setUserId(input())
|
||||
else:
|
||||
decrypt.setUser(args.user)
|
||||
print("Please enter the master password:")
|
||||
user_password = getpass()
|
||||
decrypt.setUserPassword(getpass())
|
||||
print("Decrypting User File...")
|
||||
decrypt.decryptUserFile();
|
||||
exit()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user