-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_criptografia.py
106 lines (91 loc) · 4.55 KB
/
test_criptografia.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
"""Arquivo para testes de unidade"""
from criptografia import criptografar
def criptografar_teste(chave: str, mensagem: str) -> None:
""" Realiza o teste para verificar se a mensagem original
é igual a descriptografada, caso conrtrário, retorna um erro. """
criptografado = criptografar(chave, mensagem)
descriptografado = criptografar(chave, criptografado)
assert mensagem == descriptografado
def testes():
"""
Chama a função criptografar_teste para testar cada caso.
Teste para varios casos especificos, todos com sucesso.
"""
#Normal
criptografar_teste(
chave="Chave inserida aqui para criar o fluxo",
mensagem="Mensagem a ser criptografada")
#Numeros
criptografar_teste(
chave="123454321013245684844512",
mensagem="543212345432115616558")
#Char Especial
criptografar_teste(
chave="#+@ $_% ^-&=D ]-[()",
mensagem="@#@!@#$12_= 123*48abc84 @&#@#")
#Char Escape
criptografar_teste(
chave="\t123\t321\n__\-",
mensagem="\r123\n242GG82\t11")
#Mensagem Longa
criptografar_teste(
chave="abcdefghijklkmsmhent",
mensagem="aaaaaaaaaaa aaaaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaabcde")
#Chave Longa
criptografar_teste(
chave="aaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa aaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaa aaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaabcde",
mensagem="abcdefghijklmnopqrstuvwyxz123456790")
#Ambos Longos
criptografar_teste(
chave="@@lskiia__ sajidij lalislooo sjiajisjjssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjaijssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjaijssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjjisjaijssise" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjaijssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjjisjaijssise" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjaijssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjaijssisabcde" +
"@@lskiia__ sajidij lallaoiislooo sjiajisjjisjaijssise" +
"@@lskiia__ sajidij lallaoiislooo sjiajjaijssisabcde",
mensagem="aaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaabcde" +
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaabcde")
#Chave com apenas um espaço em branco
criptografar_teste(
chave=" ",
mensagem="A chave esta com um espaco em branco")
#Mensagem com apenas um espaço em branco
criptografar_teste(
chave="A mensagem esta com um espaco em branco",
mensagem=" ")
#Se um dos testes não der True essa mensagem não aparece
print("Se essa mensagem apareceu, tudo funcionou como deveria")
if __name__ == "__main__":
testes()