-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (32 loc) · 1.06 KB
/
main.py
File metadata and controls
36 lines (32 loc) · 1.06 KB
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
import requests
import json
import hashlib
request = requests.get('https://api.codenation.dev/v1/challenge/dev-ps/generate-data?token=00691d0f48af1e80c4f04f64dc3a7fbf4df12bd8')
resposta = request.json()
arquivo = open('answer.json', "w")
json.dump(resposta, arquivo)
arquivo.close()
msg = resposta['cifrado']
s = ''
for c in msg:
if chr(ord(c)).isidentifier():
if (ord(c) - resposta['numero_casas']) < 97:
s += chr(ord(c) - resposta['numero_casas'] + 26)
else:
s += chr(ord(c) - resposta['numero_casas'])
else:
s += chr(ord(c))
dados = {
'numero_casas': resposta['numero_casas'],
'token': resposta['token'],
'cifrado': resposta['cifrado'],
'decifrado': s,
'resumo_criptografico': hashlib.sha1(s.encode()).hexdigest()
}
arquivo = open('answer.json', "w")
json.dump(dados, arquivo)
arquivo.close()
url = 'https://api.codenation.dev/v1/challenge/dev-ps/submit-solution?token=00691d0f48af1e80c4f04f64dc3a7fbf4df12bd8'
files = {'answer': open('answer.json', 'rb')}
r = requests.post(url, files=files)
r.text