-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcriptografia
More file actions
executable file
·48 lines (45 loc) · 992 Bytes
/
Copy pathcriptografia
File metadata and controls
executable file
·48 lines (45 loc) · 992 Bytes
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
#!/home/rfa/anaconda3/bin/python3
#program for crypt and uncrypt informations
file1 = open('encriptado','w')
file2 = open('decriptado','w')
def decrypt(text):
exam=list(text)
lista=[];i=0
for ch in exam:
if ch == "#":
lista.append(ch)
else:
value=ord(str(ch))
if i % 2 == 0:
value = value - 7
else:
value = value + 7
lista.append(chr(value))
i+=1
decriptado=("".join(lista).strip('[]'))
print(lista)
decriptado=decriptado.replace("#"," ")
return decriptado
def encrypt(text):
exam=list(text)
lista=[];i=0
for ch in exam:
if ch == " ":
value = ord("#")
else:
value=ord(str(ch))
if i % 2 == 0:
value = value + 7
else:
value = value - 7
lista.append(chr(value))
i+=1
encriptado=("".join(lista).strip('[]'))
return encriptado
frasechave=('O professor Carlos fará uma prova difícil.')
valor=frasechave
#valor=input('Insira uma mensagem'+'\n')
secret=encrypt(valor)
file1.write(secret)
real=decrypt(secret)
file2.write(real)