15-Lab4 CNS
15-Lab4 CNS
Batch 1
GR-no 12110238
Roll no 15
CNS Lab-4
(Simulation)
(Assignment)
2.
(Simulation)
2. Implement CEASER CIÏER code in python oí matlab and submit the same.
import tkinter as tk
from tkinter import messagebox
def encrypt_button_click():
plaintext =
plaintext_entry.get() shift =
int(shift_entry.get()) if 0 <=
shift <= 25:
encrypted_text = caesar_cipher_encrypt(plaintext, shift)
result_text.config(text="Encrypted: " + encrypted_text)
else:
messagebox.showerror("Error", "Shift value should be between 0 and 25")
def decrypt_button_click():
encrypted_text = encrypted_entry.get()
shift = int(shift_entry.get())
if 0 <= shift <= 25:
decrypted_text = caesar_cipher_decrypt(encrypted_text,
shift) result_text.config(text="Decrypted: " +
decrypted_text) else:
messagebox.showerror("Error", "Shift value should be between 0 and 25")
def clear_button_click():
plaintext_entry.delete(0, 'end')
encrypted_entry.delete(0, 'end')
shift_entry.delete(0, 'end')
result_text.config(text="")
encrypt_button = tk.Button(window,
text="Encrypt", command=encrypt_button_click)
encrypt_button.pack()
decrypt_button = tk.Button(window,
text="Decrypt", command=decrypt_button_click)
decrypt_button.pack()
clear_button = tk.Button(window,
text="Clear", command=clear_button_click)
clear_button.pack()
window.mainloop()
Output :