Pytho Tkinder ile şifreleme arayüz tasarlamak istiyorum ama kodu düzene sokamadım.(Uyarlamak istediğim kodu aşağıda paylaştım) Teşekkür ederim.
from tkinter import *
from pymongo.pool import key
class Kripto(Frame):
LETTERS = "abcdefghijklmnopqrstuvwxyz"
def __init__(self, pencere):
Frame.__init__(self, pencere)
self.pencere = pencere
Label(pencere, text="Metin Şifresi: ", relief=GROOVE, width=20).place(x=20, y=30)
self.Ent1 = Entry(pencere, width=30)
self.Ent1.place(x=170, y=30)
Label(pencere, text="Key Giriniz: ", relief=GROOVE, width=20).place(x=20, y=90)
self.Ent2 = Entry(pencere, width=30)
self.Ent2.place(x=170, y=90)
Button(pencere, text="Temizle", relief=GROOVE, font="bold",command=self.temizle).place(x=390, y=380)
Button(pencere, text="Ana Menü", relief=GROOVE, font="bold").place(x=500, y=380)
Button(pencere, text="Encrypt", relief=GROOVE, font="bold", command=self.Encrypt).place(x=50, y=150)
Button(pencere, text="Decrypt", relief=GROOVE, font="bold", command=self.Decrypt).place(x=110, y=150)
self.RESULT = Entry(pencere, width=40)
self.RESULT.place(x=170, y=200)
def temizle(self):
self.Ent2.delete(0, 'end')
self.Ent1.delete(0, 'end')
self.RESULT.delete(0, 'end')
def Encrypt(self,shift,target):
key=int(self.Ent2.get())
LETTERS = "abcdefghijklmnopqrstuvwxyz"
encrypted_string=''
for index in range(len(LETTERS)):
if LETTERS[index]==target:
x=index+shift
y=x%len(LETTERS)
return LETTERS[y]
self.RESULT.delete(0,END)
self.RESULT.insert(0,encrypted_string)
def Decrypt(self):
shift = int(self.Ent2.get())
string = len(self.LETTERS)
decrypted_string=''
shiftstr = str(shift)
for index in range(len(string)):
a=index
for index in range(len(shiftstr)):
b=index
if a%len(shiftstr)==b:
decrypted_string += self.Decrypt(key[a], int(shiftstr[b]))
self.RESULT.delete(0, END)
self.RESULT.insert(0, decrypted_string)
if __name__ == "__main__":
root = Tk()
root.title("Sezar")
root.geometry("700x700+50+50")
Kripto(root).pack(side="top", fill="both")
root.mainloop()```
Uyarlamak istediğim kod ise:
alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
tr_alphabet="ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ"
def cypher(target,shift):
for index in range(len(alphabet)):
if alphabet[index]==target:
x=index+shift
y=x%len(alphabet)
return alphabet[y]
string=input("Metin Giriniz:") #reenforcementsbeingrushed #REENFORCEMENTSBEINGRUSHED
string=string.upper()
print("Metin: ", string)
shift=int(input("Şifre Giriniz:")) #74030274
shiftstr=str(shift)
encrypted_string=''
for index in range(len(string)):
a=index
for index in range(len(shiftstr)):
b=index
if a%len(shiftstr) == b:
encrypted_string+=cypher(string[a],int(shiftstr))
print("Encrypted :",encrypted_string) #YIEQFQYGLQEQTUIIPRGUUUOIK
decrypted_string=''
for index in range(len(encrypted_string)):
a=index
for index in range(len(shiftstr)):
b=index
if a%len(shiftstr) == b:
decrypted_string+=cypher(encrypted_string[a],-int(shiftstr))
print("Decrypted : ",decrypted_string)
Şimdiden teşekkür ederim.