-
Notifications
You must be signed in to change notification settings - Fork 0
/
json-encrypt
executable file
·31 lines (29 loc) · 1.21 KB
/
json-encrypt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
import sys
from jsoncrypt import *
if "display" in sys.argv and len(sys.argv) > 2:
sys.argv.remove("display")
filename = sys.argv[1]
print(Encrypt.jsonfile(filename))
elif "help" in sys.argv or "-h" in sys.argv or "-help" in sys.argv:
print("\nJson encryption")
print("Usage:")
print("display filename_path -> To display the encryption of a file without changing the file")
print("help | -h | -help -> To see these options")
print("-p filename_path password -> To encrypt a file with a password")
print("json-encrypt filename_path -> To encrypt a file without a password\n")
elif len(sys.argv) >= 2:
if "-p" in sys.argv and len(sys.argv) >= 4:
sys.argv.remove("-p")
filename = sys.argv[1]
password = sys.argv[2]
if Encrypt.jsonfile(filename, save_file=True, password=password):
print("Successfully encrypted with password")
else:
print("Failed to encrypt file {}".format(filename))
else:
filename = sys.argv[1]
if Encrypt.jsonfile(filename, save_file=True):
print("Successfully encrypt")
else:
print("Failed to encrypt file {}".format(filename))