-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
51 lines (50 loc) · 1.9 KB
/
main.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
### Author: Mrinal Pande
### Date: Aug,15 2017
import sys
import os.path
import encrypt
import decrypt
def main():
print("---------------------------------------------------")
print("Music Encrypt - Music Based Encryption")
print("Author: Mrinal Pande")
print("---------------------------------------------------")
if len(sys.argv) < 2:
print("Invalid input \nFor Help:",sys.argv[0],"-h")
elif sys.argv[1] == "-h":
print("Help For Music Encrypt")
print("---------------------------------------------------")
print("Options Description")
print("-f File to encrypt/Decrypt")
print("-e Encrypt the file")
print("-d Decrypt the file")
print("-k Key to Encrypt")
print("-o name of output file")
print("\nFor encrypting a file:")
print("python main.py -f <filename> -e -k <key> -o <output file name>")
print("\nFor decrypting a file:")
print("python main.py -f <filename> -d -k <key>")
print("---------------------------------------------------")
elif sys.argv[3] == "-e" and len(sys.argv) == 8:
fpath = sys.argv[2]
key = sys.argv[5]
outfile = sys.argv[7]
print("Starting Encryption...")
if os.path.isfile(fpath):
encrypt.encrypt(fpath,key,outfile)
else:
print("File not found \n")
print("Invalid input\nFor Help:",sys.argv[0],"-h")
elif sys.argv[3] == "-d" and len(sys.argv) == 6:
print("Decryption")
fpath = sys.argv[2]
key = sys.argv[5]
print("Starting decryption...")
if os.path.isfile(fpath):
decrypt.decrypt(fpath,key)
else:
print("File not found \n")
print("Invalid input\nFor Help:",sys.argv[0],"-h")
else:
print("Invalid input\nFor Help:",sys.argv[0],"-h")
main()