-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRun.py
More file actions
52 lines (37 loc) · 1.2 KB
/
Run.py
File metadata and controls
52 lines (37 loc) · 1.2 KB
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
52
import random
import sys
sys.path.append("./File/Cipher")
sys.path.append("./File/Key")
sys.path.append("./File")
sys.path.append("./StoredKey")
from edFile import *
from edKey import *
loop = True
while loop:
print('1.Encrypt 2.Decrypt Other-->Exit')
menu = input('Type number to choose menu: ')
if menu == '1':
filename = input('Type the file name you want to encrypt: ')
key = random.randint(100,400)
keytext = EncryptKey(key, len(filename))
Encrypt(filename,key)
filekey = open('StoredKey/'+filename+'key.txt', 'wb')
filekey.write(keytext.encode())
filekey.close()
print('Encryption Success')
print()
elif menu == '2':
filename = input('Type the file name you want to decrypt: ')
filekey = open('StoredKey/'+filename+'key.txt', 'rb')
keytext = filekey.read()
filekey.close()
key = DecryptKey(keytext.decode(), len(filename))
Decrypt(filename,key)
print('Decryption Success')
print()
filekey = open('StoredKey/'+filename+'key.txt', 'w')
filekey.write('')
filekey.close()
else:
print('Exit')
loop = False