Question: Using the AES - ECB encryptor from the cryptography.io module, implement the AES mode in Figure 1 . You can instantiate an AES - ECB
Using the AESECB encryptor from the cryptography.io module, implement the
AES mode in Figure You can instantiate an AESECB encryptor as follows:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms,
modes
key # SELECT AN APPROPRIATE KEY FOR AES
cipher CipheralgorithmsAESkey modes.ECB
encryptor cipher.encryptor
The function's name has to be CustomAESmode and defined as follows:
# START OF YOUR CODERUNNER SUBMISSION CODE
# INCLUDE ALL YOUR IMPORTS HERE
def CustomAESModekey: bytes, iv: bytes, plaintext: str str:
# YOUR IMPLEMENTATION
return # THE CIPHERTEXT
# END OF YOUR CODERUNNER SUBMISSION CODE
#You can test your code in your system NOT IN YOUR CODERUNNER SUBMISSION
as follows:
# MAIN
if namemain:
key bytes.fromhexababed
iv bytes.fromhexdafbadebbdacfac
txt "This is a text"
print CustomAESModekey iv txt
# The result using the above input should be:
bfcfaebbcafcd
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
