Mah D Assignment
Mah D Assignment
ASSIGNMENT # 02
NAME : Mahd-ul-haq
Python Code
import math
key='3456'
# Encryption
def encryptMessage(msg):
cipher = ""
msg_len = float(len(msg))
msg_lst = list(msg)
key_lst = sorted(list(key))
# calculate column of the matrix
col = len(key)
return cipher
# Decryption
def decryptMessage(cipher):
msg = ""
for j in range(row):
dec_cipher[j][curr_idx] = msg_lst[msg_indx]
msg_indx += 1
k_indx += 1
null_count = msg.count('_')
if null_count > 0:
return msg[: -null_count]
return msg
cipher=encryptMessage(msg)
print("Encrypted Message : ",cipher)
plaintext=decryptMessage(cipher)
with open("plain.txt","w") as file:
file.write(plaintext)
Implementation In VS Code