mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2024-11-21 17:51:05 +01:00
optimized cli workflow
This commit is contained in:
parent
72765e280d
commit
e4217afe64
@ -20,6 +20,10 @@ street in strasdlasöd
|
||||
END_OF_INPUTS
|
||||
python scripts/main.py --mode decrypt --master-password "ewrwerwerew" &&
|
||||
python scripts/main.py --mode decrypt --user "1"
|
||||
|
||||
|
||||
python scripts/main.py --mode cleanup --user "1" && python scripts/main.py --mode decrypt --user "1" --user-password "O3ITMWXZED9FKYQ0PB2WNVRWSCSCYVXCD00PJ6GQ4MFPIUWBVDCYSSSX9ZDBW5QU"
|
||||
|
||||
```
|
||||
# Requirements to know
|
||||
- Amount of People
|
||||
|
@ -26,7 +26,11 @@ class Cleanup(AbstractSplittedSecret):
|
||||
self.deleteAllFilesInFolder(folder_path)
|
||||
|
||||
def cleanupForUser(self,user):
|
||||
self.executeCommand('find "' + self.getFolderPath("encrypted") + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
try:
|
||||
self.executeCommand('find "' + self.getFolderPath("encrypted") + '" -not -name "*' + str(user) +'*" -type f -print | xargs rm -v')
|
||||
except:
|
||||
pass
|
||||
self.deleteAllFiles("decrypted")
|
||||
|
||||
def deleteAll(self):
|
||||
self.deleteAllFiles("encrypted")
|
||||
|
@ -20,6 +20,9 @@ class Decryption(AbstractSplittedSecret):
|
||||
file.close()
|
||||
return data
|
||||
|
||||
def getNeededEncryptersAmount(self):
|
||||
return len(str(list(self.user_data['groups'].keys())[0]))-1
|
||||
|
||||
def decryptFile(self,password,input_file_path,output_file_path):
|
||||
self.executeCommand('gpg --batch --passphrase "'+ password + '" -o "' + output_file_path +'" "'+ input_file_path+'"')
|
||||
|
||||
|
@ -10,6 +10,7 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=range(1,9))
|
||||
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
|
||||
parser.add_argument('--master-password',type=str, dest='master_password',required=False)
|
||||
parser.add_argument('--user-password',type=str, dest='user_password',required=False)
|
||||
parser.add_argument('--user',type=int, dest='user',choices=range(1,9),required=False)
|
||||
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction)
|
||||
args = parser.parse_args()
|
||||
@ -21,8 +22,10 @@ if __name__ == '__main__':
|
||||
if mode == 'cleanup':
|
||||
cleanup = Cleanup()
|
||||
if args.user is None:
|
||||
print("Delete all files.")
|
||||
cleanup.deleteAll()
|
||||
exit()
|
||||
print("Delete files for user <<" + str(args.user) + ">>");
|
||||
cleanup.cleanupForUser(args.user)
|
||||
exit()
|
||||
|
||||
@ -34,18 +37,31 @@ if __name__ == '__main__':
|
||||
decrypt.setUserId(input())
|
||||
else:
|
||||
decrypt.setUserId(args.user)
|
||||
while True:
|
||||
print("Please enter the user password:")
|
||||
decrypt.setUserPassword(getpass())
|
||||
if args.user_password is None:
|
||||
while True:
|
||||
print("Please enter the user password:")
|
||||
decrypt.setUserPassword(getpass())
|
||||
print("Decrypting User File...")
|
||||
try:
|
||||
decrypt.setUserData();
|
||||
break;
|
||||
except:
|
||||
print("Wrong password :(")
|
||||
else:
|
||||
decrypt.setUserPassword(args.user_password)
|
||||
print("Decrypting User File...")
|
||||
try:
|
||||
decrypt.setUserData();
|
||||
break;
|
||||
except:
|
||||
print("Wrong password :(")
|
||||
print("File decrypted :) ")
|
||||
print("Please contact ")
|
||||
print(decrypt.user_data)
|
||||
exit()
|
||||
print("File decrypted :) \n")
|
||||
print("Please contact the following persons and tell them that you need help to encrypt the data: \n")
|
||||
for contact_id in decrypt.user_data['contacts']:
|
||||
print("user_id: " + contact_id)
|
||||
for label in decrypt.user_data['contacts'][contact_id]:
|
||||
print(label + ": " + decrypt.user_data['contacts'][contact_id][label])
|
||||
print("You need at least <<" + str(decrypt.getNeededEncryptersAmount()) +">> aditional people to decrypt the secret.")
|
||||
exit()
|
||||
print("Decrypting accumulated file...")
|
||||
decrypt.setUserPassword(args.master_password)
|
||||
|
Loading…
Reference in New Issue
Block a user