Question: Assuming there is one client, and one server: 1 . The client acts as the sender , encrypting and encoding the message before sending it
Assuming there is one client, and one server:
The client acts as the sender encrypting and encoding the message before sending it
The client then transmits the encryptedencoded data to the server. We also assume that the
client and the server had shared the same key CS@CS spring".
Finally, when the server receives the message, it appears as
"YidDZHVvQlBURXJNSWVULpUKdEelVJbVVUEhhdmxalVUUmZQSzUvZUpuaBvZVFuUtBLdndFFNWWZOZmTJw
Please assist the server in recovering the original message. I have already provided the code.
Please fill in the missing content and run it using Python.
from cryptography.hazmat.primitives import padding
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.backends import defaultbackend
import os
import base
def encryptmessagekey message:
iv osurandom # Generate a random IV
padder padding.PKCSpadder
paddeddata padder.updatemessageencode padder.finalize
cipher CipheralgorithmsAESkey modes.CBCiv backenddefaultbackend
encryptor cipher.encryptor
ciphertext encryptor.updatepaddeddata encryptor.finalize
return basebencodeiv ciphertext
def decryptmessagekey ciphertext:
data basebdecodeciphertext
iv data:
ciphertext data:
cipher CipheralgorithmsAESkey modes.CBCiv backenddefaultbackend
decryptor cipher.decryptor
paddeddata decryptor.updateciphertext decryptor.finalize
unpadder padding.PKCSunpadder
message unpadder.updatepaddeddata unpadder.finalize
return message.decode
# Decrypt the message
decryptedmessage decryptmessagekey encryptedmessage
printDecrypted: decryptedmessage
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
