-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmulticrypt.py
137 lines (99 loc) · 5.63 KB
/
multicrypt.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# Multicrypt organisation module
"""
Padlock Encryption Software
Copyright 2019
Created by: Suraj Kothari
For A-level Computer Science
at Woodhouse College.
"""
import Caesar_Cipher
import Vigenere_Cipher
import DES_Cipher
import AES_Cipher
import RC4_Cipher
def encrypt(passKey, cipher, dataformat, plaintext=None, filename=None, filepath=None, cipherMode=None):
""" Checks the cipher used and returns the requested encrypted data """
# If the data format is message, a plaintext argument will need to be passed.
if dataformat == "Messages":
if cipher == "Caesar Cipher":
encryptedData = Caesar_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Vigenere Cipher":
encryptedData = Vigenere_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "DES Cipher":
encryptedData = DES_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat)
elif cipher == "Triple DES Cipher":
encryptedData = DES_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat, isTripleDES=True)
elif cipher == "AES Cipher":
encryptedData = AES_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat)
elif cipher == "RC4 Cipher":
encryptedData = RC4_Cipher.encrypt(plaintext=plaintext,
passKey=passKey, dataformat=dataformat)
# If the data format is either a file or an image, a filename argument will need to be passed.
else:
if cipher == "Caesar Cipher":
encryptedData = Caesar_Cipher.encrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Vigenere Cipher":
encryptedData = Vigenere_Cipher.encrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "DES Cipher":
encryptedData = DES_Cipher.encrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Triple DES Cipher":
encryptedData = DES_Cipher.encrypt(filename=filename, filepath=filepath,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode, isTripleDES=True)
elif cipher == "AES Cipher":
encryptedData = AES_Cipher.encrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "RC4 Cipher":
encryptedData = RC4_Cipher.encrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
return encryptedData
def decrypt(passKey, cipher, dataformat, ciphertext=None, filename=None, filepath=None, cipherMode=None):
""" Checks the cipher used and returns the requested decrypted data """
# If the data format is message, a ciphertext argument will need to be passed.
if dataformat == "Messages":
if cipher == "Caesar Cipher":
decryptedData = Caesar_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Vigenere Cipher":
decryptedData = Vigenere_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "DES Cipher":
decryptedData = DES_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat)
elif cipher == "Triple DES Cipher":
decryptedData = DES_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat, isTripleDES=True)
elif cipher == "AES Cipher":
decryptedData = AES_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat)
elif cipher == "RC4 Cipher":
decryptedData = RC4_Cipher.decrypt(ciphertext=ciphertext,
passKey=passKey, dataformat=dataformat)
# If the data format is either a file or an image, a filename argument will need to be passed.
else:
if cipher == "Caesar Cipher":
decryptedData = Caesar_Cipher.decrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Vigenere Cipher":
decryptedData = Vigenere_Cipher.decrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "DES Cipher":
decryptedData = DES_Cipher.decrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "Triple DES Cipher":
decryptedData = DES_Cipher.decrypt(filename=filename, filepath=filepath,
passKey=passKey, dataformat=dataformat, cipherMode=cipherMode, isTripleDES=True)
elif cipher == "AES Cipher":
decryptedData = AES_Cipher.decrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
elif cipher == "RC4 Cipher":
decryptedData = RC4_Cipher.decrypt(filename=filename,
filepath=filepath, passKey=passKey, dataformat=dataformat, cipherMode=cipherMode)
return decryptedData