mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2024-11-22 10:11: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
|
END_OF_INPUTS
|
||||||
python scripts/main.py --mode decrypt --master-password "ewrwerwerew" &&
|
python scripts/main.py --mode decrypt --master-password "ewrwerwerew" &&
|
||||||
python scripts/main.py --mode decrypt --user "1"
|
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
|
# Requirements to know
|
||||||
- Amount of People
|
- Amount of People
|
||||||
|
@ -26,7 +26,11 @@ class Cleanup(AbstractSplittedSecret):
|
|||||||
self.deleteAllFilesInFolder(folder_path)
|
self.deleteAllFilesInFolder(folder_path)
|
||||||
|
|
||||||
def cleanupForUser(self,user):
|
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):
|
def deleteAll(self):
|
||||||
self.deleteAllFiles("encrypted")
|
self.deleteAllFiles("encrypted")
|
||||||
|
@ -20,6 +20,9 @@ class Decryption(AbstractSplittedSecret):
|
|||||||
file.close()
|
file.close()
|
||||||
return data
|
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):
|
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+'"')
|
||||||
|
|
||||||
|
@ -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('--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('--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('--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('--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)
|
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@ -21,8 +22,10 @@ if __name__ == '__main__':
|
|||||||
if mode == 'cleanup':
|
if mode == 'cleanup':
|
||||||
cleanup = Cleanup()
|
cleanup = Cleanup()
|
||||||
if args.user is None:
|
if args.user is None:
|
||||||
|
print("Delete all files.")
|
||||||
cleanup.deleteAll()
|
cleanup.deleteAll()
|
||||||
exit()
|
exit()
|
||||||
|
print("Delete files for user <<" + str(args.user) + ">>");
|
||||||
cleanup.cleanupForUser(args.user)
|
cleanup.cleanupForUser(args.user)
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
@ -34,18 +37,31 @@ if __name__ == '__main__':
|
|||||||
decrypt.setUserId(input())
|
decrypt.setUserId(input())
|
||||||
else:
|
else:
|
||||||
decrypt.setUserId(args.user)
|
decrypt.setUserId(args.user)
|
||||||
while True:
|
if args.user_password is None:
|
||||||
print("Please enter the user password:")
|
while True:
|
||||||
decrypt.setUserPassword(getpass())
|
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...")
|
print("Decrypting User File...")
|
||||||
try:
|
try:
|
||||||
decrypt.setUserData();
|
decrypt.setUserData();
|
||||||
break;
|
|
||||||
except:
|
except:
|
||||||
print("Wrong password :(")
|
print("Wrong password :(")
|
||||||
print("File decrypted :) ")
|
exit()
|
||||||
print("Please contact ")
|
print("File decrypted :) \n")
|
||||||
print(decrypt.user_data)
|
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()
|
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