-
Notifications
You must be signed in to change notification settings - Fork 0
/
crip.py
108 lines (78 loc) · 2.99 KB
/
crip.py
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#----------------------------------------------------------------------------------------
# Software que gera codigo aleatorio de mensagem
# Data de Criacao: 01-2021
# Autor: Athila Wender de Salles
#----------------------------------------------------------------------------------------
import PySimpleGUI as tela
import random
#----Area de tela e tema-----------------------------------------------------------------
tela.theme('DarkGrey')
informacao=[
[tela.Radio('Mensagem a ser codificada', 'RADIO1', default=True,key='-COD-')],
[tela.Radio('Codigo a ser traduzido','RADIO1',default=False,key='-MEM-')],
[tela.Multiline(size=(50,15),key='-IN-')]
]
resultado=[
[tela.Text('Resultado')],
[tela.Text(' ')],
[tela.Multiline(size=(50,15),key='-OUT-')]
]
layout =[
[tela.Column(informacao),tela.VerticalSeparator(),tela.Column(resultado)],
[tela.Button('Executar'), tela.Button('Limpar'), tela.Button('Sair')]
]
janela = tela.Window('CripTest', layout, icon='virus.ico')
#----Inicio do Software------------------------------------------------------------------
while True:
event,values = janela.read()
# termina os eventos para sair
if event == tela.WIN_CLOSED or event =='Sair':
break
# limpa a tela
if event == 'Limpar':
janela['-IN-'].update('')
janela['-OUT-'].update('')
# captura o texto da caixa de texto
if event == 'Executar':
ini= int(100*(random.random()))
cod=''
pos =0
carac=''
posi=0
men = {"testo":values['-IN-']}
men2 =men['testo']
tam=len(men2)
if int(ini) <100 and int(ini)>10:
ini = '0'+str(ini)
if int(ini)<10:
ini = '00'+str(ini)
# executa a codificacao do texto
if values['-COD-'] == True:
for c in men2:
carac =str(ord(men2[pos]))
carac =int(carac)+int(ini)
if int(carac)<10:
carac = '00'+str(carac)
if int(carac)<100 and int(carac)>10:
carac='0'+str(carac)
cod=cod+str(carac)
pos=pos+1
cod =str(ini) + cod
# executa a traducao do codigo
if values['-MEM-']==True:
for c in men2:
carac = carac + men2[pos]
if posi == 2:
if pos == 2:
ini = int(carac)
carac = int(carac)-int(ini)
if carac > 0:
cod = cod +(chr(int(carac)))
carac = ''
posi = -1
posi = posi +1
pos = pos +1
# manda o resultado para tela
janela["-OUT-"].update(cod)
janela.close()
#----Fim do programa---------------------------------------------------------------------