-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (25 loc) · 671 Bytes
/
main.py
File metadata and controls
32 lines (25 loc) · 671 Bytes
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
32
from pyAesCrypt import encryptFile, decryptFile
import sys
import os
import time
bufferSize = 64 * 1024
path = sys.argv[1]
action = sys.argv[2]
password = sys.argv[3]
try:
# encryption
if action in "encrypt":
encryptFile(path, f"{path}.aes", password, bufferSize)
os.remove(path)
print("Successfully encrypted your file!")
# decrypt
elif action in "decrypt":
decryptFile(path, path[:-4], password, bufferSize)
os.remove(path)
print("Successfully decrypted your file!")
else:
print(action + "\nEnter a valid action!")
except Exception as error:
print(error)
finally:
time.sleep(1)