-
Notifications
You must be signed in to change notification settings - Fork 1
/
Decryption.py
72 lines (53 loc) · 2.04 KB
/
Decryption.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import sys
import os
def findfile(name, path):
for dirpath, dirname, filename in os.walk(path):
if name in filename:
return os.path.join(dirpath, name)
sys.path.insert(0,findfile('AffineDecryption.py','/users'))
sys.path.insert(0,findfile("HillDecryption.py",'/users'))
sys.path.insert(0,findfile("PermutationDecryption.py",'/users'))
sys.path.insert(0,findfile("ShiftDecryption.py",'/users'))
sys.path.insert(0,findfile("VignereDecryption.py",'/users'))
sys.path.insert(0,findfile("SubstitutionDecryption.py",'/users'))
from AffineCipher import AffineDecryption
from ShiftCipher import ShiftDecryption
from SubstitutionCipher import SubstitutionDecryption
from VignereCipher import VignereDecryption
from HillCipher import HillDecryption
from PermutationCipher import PermutationDecryption
with open('Encrypted.txt','r') as file:
message = file.read()
randomNumList =[]
with open('Keys/randomList.txt','r') as file:
for line in file:
randomNumList.append(int(line))
# print(randomNumList)
def decryption(argument):
match argument:
case 1:
return AffineDecryption.decryption(message)
case 2:
return HillDecryption.decryption(message)
case 3:
return ShiftDecryption.decryption(message)
case 4:
return SubstitutionDecryption.decryption(message)
case 5:
return VignereDecryption.decryption(message)
case 6:
return PermutationDecryption.decryption(message)
message = decryption(randomNumList[5]) #message ko overwrite kar diya
# print(message)
message = decryption(randomNumList[4]) #message ko overwrite kar diya
# print(message)
message=decryption(randomNumList[3])
# print(message)
message=decryption(randomNumList[2])
# print(message)
message=decryption(randomNumList[1])
# print(message)
message=decryption(randomNumList[0])
# print(message)
with open('Decrypted.txt',"w") as file:
file.write(message)