forked from tecnico-sec/Python-Crypto-Details
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFileAESDecipher.py
More file actions
30 lines (23 loc) · 866 Bytes
/
Copy pathFileAESDecipher.py
File metadata and controls
30 lines (23 loc) · 866 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
from sys import argv
from AESCipherByteArrayMixer import AESCipherByteArrayMixer
from FileMixer import FileMixer
class FileAESDecipher:
def run(argv):
inputFile = argv[1]
keyFile = argv[2]
mode = argv[3].upper()
outputFile = argv[4]
if not (mode == "ECB" or mode == "CBC" or mode == "OFB"):
print("The modes of operation must be ECB, CBC or OFB.")
return
cipher = AESCipherByteArrayMixer("Cipher.DECRYPT_MODE")
cipher.setParameters(keyFile, mode)
FileMixer.mix1(inputFile, outputFile, cipher)
def main(argv):
if len(argv) != 5:
print("This program decrypts a file with AES.")
print("Usage: FileAESDecipher [inputFile] [AESKeyFile] [ECB|CBC|OFB] [outputFile]")
return
FileAESDecipher.run(argv)
if __name__ == '__main__':
main(argv)