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 AES-ECB encryptor from the cryptography.io module, implement the
AES mode in Figure 1. You can instantiate an AES-ECB encryptor as follows:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms,
modes
key = # SELECT AN APPROPRIATE KEY FOR AES
cipher = Cipher(algorithms.AES(key), 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 CustomAESMode(key: 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 __name__=="__main__":
key = bytes.fromhex("06a9214036b8a15b512e03d534120006")
iv = bytes.fromhex("3dafba429d9eb430b422da802c9fac41")
txt = "This is a text"
print( CustomAESMode(key, iv, txt))
# The result using the above input should be:
1827bfc04f1a455eb101b943c44afc1d

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!