├── Decryption.py ├── Encryption.py ├── EncryptionProject.py └── README.md /Decryption.py: -------------------------------------------------------------------------------- 1 | from tkinter import messagebox 2 | from tkinter import * 3 | 4 | 5 | class DecGui: 6 | 7 | def __init__(self): 8 | print("call dec gui") 9 | dec_root = Tk() 10 | dec_root.title("Decryption") 11 | self.plain_text = StringVar(dec_root, value="") 12 | dec_root.geometry("400x300+300+300") 13 | decrypt_entry = Entry(dec_root, textvariable=self.plain_text).grid(row=1, column=1) 14 | dec_button = Button(dec_root, text="Decrypt", command=lambda: self.decryption_process()).grid(row=1, column=2) 15 | # enc_button.bind(" ", ) 16 | dec_root.mainloop() 17 | 18 | def decryption_process(self): 19 | print("pressed") 20 | decrypted_text = decrypt(self.plain_text.get()) 21 | print(decrypted_text) 22 | messagebox.showinfo("decrypted", decrypted_text) 23 | 24 | 25 | def decrypt(ss): 26 | st = list(ss) 27 | i = len(st) // 2 28 | while i < len(st): 29 | st[i] = chr((ord(st[i]) + 1)) 30 | i += 1 31 | 32 | st = ''.join(reversed(st)) # reverse the list using reversed() function << 33 | st = list(st) 34 | 35 | for i, char in enumerate(st): 36 | if chr(ord('a')+3) <= st[i] <= chr(ord('z')+3) or chr(ord('A')+3) <= st[i] <= chr(ord('Z')+3): 37 | st[i] = (chr(ord(st[i]) - 3)) 38 | 39 | return ''.join(st) 40 | -------------------------------------------------------------------------------- /Encryption.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from tkinter import messagebox 3 | 4 | 5 | class EncGui: 6 | 7 | def __init__(self): 8 | print("call enc gui") 9 | enc_root = Tk() 10 | enc_root.title("Encryption") 11 | self.plain_text = StringVar(enc_root, value="") 12 | enc_root.geometry("400x300+300+300") 13 | encrypt_entry = Entry(enc_root, textvariable=self.plain_text).grid(row=1, column=1) 14 | enc_button = Button(enc_root, text="Encrypt", command=lambda: self.encryption_process()).grid(row=1, column=2) 15 | # enc_button.bind(" ", ) 16 | enc_root.mainloop() 17 | 18 | def encryption_process(self): 19 | print("pressed") 20 | encrypted_text = encrypt(self.plain_text.get()) 21 | print(encrypted_text) 22 | messagebox.showinfo("encrypted", encrypted_text) 23 | 24 | 25 | def encrypt(strr): 26 | i = 0 27 | st = list(strr) 28 | for i, char in enumerate(st): 29 | if 'a' <= st[i] <= 'z' or 'A' <= st[i] <= 'Z': 30 | st[i] = (chr(ord(st[i]) + 3)) 31 | 32 | st = st[::-1] # reverse the list 33 | st = list(st) 34 | i = len(st)//2 35 | 36 | while i < len(st): 37 | st[i] = (chr(ord(st[i]) - 1)) 38 | 39 | i += 1 40 | 41 | return ''.join(st) 42 | 43 | -------------------------------------------------------------------------------- /EncryptionProject.py: -------------------------------------------------------------------------------- 1 | from Encryption import * 2 | from Decryption import * 3 | from tkinter import * 4 | 5 | 6 | class Message: 7 | def __init__(self, root): 8 | root.title("Crypto Text") 9 | root.geometry("400x200+300+300") 10 | # to_process_text = StringVar(root, value="Enter your text Here!!!") 11 | self.encryptButton = Button(root, text="Encrypt My Text", command=lambda: EncGui()).grid(row=1, column=1) 12 | self.decryptButton = Button(root, text="Decrypt My Text", command=lambda: DecGui()).grid(row=1, column=2) 13 | 14 | 15 | root = Tk() 16 | 17 | Mes = Message(root) 18 | 19 | root.mainloop() 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # encryption 2 | run EncryptionProject.py file 3 | --------------------------------------------------------------------------------