1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| i
#---------------------------------------------- MODELE CESAR FORCE BRUTE
#--------------------------------------root
#----------------------------------------------
from tkinter import *
import tkinter as tk
import string
root = tk.Tk()
#----------------------------------------------
#--------------------------------------root
#----------------------------------------------
root.geometry("600x600")
root.configure(bg='wheat4')
init_dir='D:\\testing\\file-menu\\' # folder to work
#-----------------------------------------------------Text box
fenet1 = tk.Text(root, height=20, width=50 ,bg='powderblue' , borderwidth=2, wrap=WORD) #
fenet1.place(x=50, y=50)
#======================= brute force tableau
# Get cipher text
def decrypt_cesar(ciphertext):
for key in range(1, 26):
plain_text = ''
for char in ciphertext:
if char.isalpha():
shift = ord(char) - key
if char.isupper():
if shift < ord('A'):
shift += 26
else:
if shift < ord('a'):
shift += 26
plain_text += chr(shift)
else:
plain_text += char
print('Key : ', key, 'Deciphered Text : ', plain_text)
sequence = ( "Key : ", key, "Deciphered Text : ", plain_text, "\n")
fenet1.insert(tk.END, sequence)
toto = "azertyu"
decrypt_cesar(toto) |
Partager