forked from barbosa46/Python-Crypto-Details
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileAESCipher.py
More file actions
30 lines (23 loc) · 860 Bytes
/
Copy pathFileAESCipher.py
File metadata and controls
30 lines (23 loc) · 860 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 FileAESCipher:
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.ENCRYPT_MODE")
cipher.setParameters(keyFile, mode)
FileMixer.mix1(inputFile, outputFile, cipher)
def main(argv):
if len(argv) != 5:
print("This program encrypts a file with AES.")
print("Usage: FileAESCipher [inputFile] [AESKeyFile] [ECB|CBC|OFB] [outputFile]")
return
FileAESCipher.run(argv)
if __name__ == '__main__':
main(argv)