forked from tecnico-sec/Python-Crypto-Details
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathImageAESCipher.py
More file actions
29 lines (21 loc) · 791 Bytes
/
Copy pathImageAESCipher.py
File metadata and controls
29 lines (21 loc) · 791 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
from sys import argv
from AESCipherByteArrayMixer import AESCipherByteArrayMixer
from ImageMixer import ImageMixer
def main(argv):
if (len(argv) != 5):
print("This program encrypts an image file with AES.");
print("Usage: ImageAESCipher [inputFile.png] [AESKeyFile] [ECB|CBC|OFB] [outputFile.png]");
return
inputFile = argv[1]
keyFile = argv[2]
mode = argv[3]
outputFile = argv[4]
if mode != "ECB" and mode != "CBC" and mode != "OFB":
print("The modes of operation must be ECB, CBC or OFB.");
return
cipher = AESCipherByteArrayMixer("Cipher.ENCRYPT_MODE")
cipher.setParameters(keyFile, mode)
ImageMixer.mix(inputFile, outputFile, cipher);
print("Done.")
if __name__ == '__main__':
main(argv)