Encryption and Decryption Python Code title: Contents style: nestedList # TOC style (nestedList|inlineFirstLevel) minLevel: 1 # Include headings from the specified level maxLevel: 4 # Include headings up to the specified level includeLinks: true # Make headings clickable debugInConsole: false # Print debug info in Obsidian console Overview Sources: ** Code encrypt.py: from tkinter import messagebox, simpledialog, Tk def is_even(number): return number % 2 == 0 def get_even_letters(message): even_letters = [] for counter in range(0, len(message)): if is_even(counter): even_letters.append(message[counter]) return even_letters def get_odd_letters(message): odd_letters = [] for counter in range(0, len(message)): if not is_even(counter): odd_letters.append(message[counter]) return odd_letters def swap_letters(message): letter_list = [] if not is_even(len(message)): message = message + 'x' even_letters = get_even_letters(message) odd_letters = get_odd_letters(message) for counter in range(0, int(len(message)/2)): letter_list.append(odd_letters[counter]) letter_list.append(even_letters[counter]) new_message = ''.join(letter_list) return new_message def get_task(): task = simpledialog.askstring('Task', 'Do you want to encrypt or decrypt?') return task def get_message(): message = simpledialog.askstring('Message', 'Enter the secret message: ') return message root = Tk() while True: task = get_task() if task == 'encrypt': message = get_message() encrypted = swap_letters(message) messagebox.showinfo('Ciphertext of the secret message is:', encrypted) elif task == 'decrypt': message = get_message() decrypted = swap_letters(message) messagebox.showinfo('Plaintext of the secret message is:', decrypted) else: break root.mainloop() Details About This note is about … See Also Python Map of Content Python Code Tool - Python Tool - Python Flask Appendix Note created on 2024-04-23 and last modified on 2024-04-23. Backlinks LIST FROM [[Python - Encryption and Decryption]] AND -"CHANGELOG" AND -"04-RESOURCES/Code/Python/Python - Encryption and Decryption" (c) No Clocks, LLC | 2024