mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2024-11-22 10:11:05 +01:00
Implemented loading of json file
This commit is contained in:
parent
0831ab3448
commit
72765e280d
@ -1,4 +1,5 @@
|
|||||||
from .AbstractSplittedSecret import AbstractSplittedSecret
|
from .AbstractSplittedSecret import AbstractSplittedSecret
|
||||||
|
import json
|
||||||
class Decryption(AbstractSplittedSecret):
|
class Decryption(AbstractSplittedSecret):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -8,19 +9,29 @@ class Decryption(AbstractSplittedSecret):
|
|||||||
|
|
||||||
def setUserId(self,user_id):
|
def setUserId(self,user_id):
|
||||||
self.user_id=str(user_id)
|
self.user_id=str(user_id)
|
||||||
|
self.user_file_decrypted_path = self.getUserFilePath(self.user_id,"decrypted")
|
||||||
|
|
||||||
def setUserPassword(self,user_password):
|
def setUserPassword(self,user_password):
|
||||||
self.user_password = str(user_password)
|
self.user_password = str(user_password)
|
||||||
|
|
||||||
|
def loadJsonFile(self,file_path):
|
||||||
|
file = open(file_path)
|
||||||
|
data = json.load(file)
|
||||||
|
file.close()
|
||||||
|
return data
|
||||||
|
|
||||||
def decryptFile(self,password,input_file_path,output_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+'"')
|
self.executeCommand('gpg --batch --passphrase "'+ password + '" -o "' + output_file_path +'" "'+ input_file_path+'"')
|
||||||
|
|
||||||
def decryptUserFile(self):
|
def decryptUserFile(self):
|
||||||
input_file_path = self.getUserFilePath(self.user_id,"encrypted")
|
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, self.user_file_decrypted_path)
|
||||||
self.decryptFile(self.user_password, input_file_path, output_file_path)
|
|
||||||
|
|
||||||
def decryptAccumulatedFile(self):
|
def decryptAccumulatedFile(self):
|
||||||
input_file_path = self.getAccumulatedFilePath("encrypted")
|
input_file_path = self.getAccumulatedFilePath("encrypted")
|
||||||
output_file_path = self.getAccumulatedFilePath("decrypted")
|
output_file_path = self.getAccumulatedFilePath("decrypted")
|
||||||
self.decryptFile(self.user_password, input_file_path, output_file_path)
|
self.decryptFile(self.user_password, input_file_path, output_file_path)
|
||||||
|
|
||||||
|
def setUserData(self):
|
||||||
|
self.decryptUserFile()
|
||||||
|
self.user_data = self.loadJsonFile(self.user_file_decrypted_path)
|
@ -39,11 +39,13 @@ if __name__ == '__main__':
|
|||||||
decrypt.setUserPassword(getpass())
|
decrypt.setUserPassword(getpass())
|
||||||
print("Decrypting User File...")
|
print("Decrypting User File...")
|
||||||
try:
|
try:
|
||||||
decrypt.decryptUserFile();
|
decrypt.setUserData();
|
||||||
break;
|
break;
|
||||||
except:
|
except:
|
||||||
print("Wrong password :(")
|
print("Wrong password :(")
|
||||||
print("File encrypted :) ")
|
print("File decrypted :) ")
|
||||||
|
print("Please contact ")
|
||||||
|
print(decrypt.user_data)
|
||||||
exit()
|
exit()
|
||||||
print("Decrypting accumulated file...")
|
print("Decrypting accumulated file...")
|
||||||
decrypt.setUserPassword(args.master_password)
|
decrypt.setUserPassword(args.master_password)
|
||||||
|
Loading…
Reference in New Issue
Block a user