Skip to content

Instantly share code, notes, and snippets.

@nenodias
Last active June 1, 2019 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nenodias/aa7d314794521b34b4a8c9002ba43e6c to your computer and use it in GitHub Desktop.
Save nenodias/aa7d314794521b34b4a8c9002ba43e6c to your computer and use it in GitHub Desktop.
Cifra.py
import sys
ALPHABET = ' abcdefghijklmnopqrstuvwxyz'
ROOT = '3'
def decrypt(message):
m = ''
for c in message:
if c in ALPHABET:
c_index = ALPHABET.index(c)
m += ALPHABET[(c_index - ROOT) % len(ALPHABET)]
else:
m =+ c
return m
def encrypt(message):
m = ''
for c in message:
c_index = ALPHABET.index(c)
if __name__ == '__main__':
command = sys.argv[1].lower()
message = sys.argv[2].lower()
if command == 'encrypt':
print(encrypt(message))
elif command == 'decrypt':
print(decrypt(message))
else:
print(command + '--> command not found')
import hashlib
texto = 'Texto a ser criptografado'
txt_sha = hashlib.sha1(texto.encode())
print(txt_sha.hexdigest())
import sys
ALPHABET = ' abcdefghijklmnopqrstuvwxyz'
ROOT = '3'
def encrypt(message):
m = ''
for c in message:
if c in ALPHABET:
c_index = ALPHABET.index(c)
m += ALPHABET[(c_index + ROOT) % len(ALPHABET)]
else:
m =+ c
return m
def decrypt(message):
m = ''
for c in message:
if c in ALPHABET:
c_index = ALPHABET.index(c)
m += ALPHABET[(c_index - ROOT) % len(ALPHABET)]
else:
m =+ c
return m
def encrypt(message):
m = ''
for c in message:
c_index = ALPHABET.index(c)
if __name__ == '__main__':
command = sys.argv[1].lower()
message = sys.argv[2].lower()
if command == 'encrypt':
print(encrypt(message))
elif command == 'decrypt':
print(decrypt(message))
else:
print(command + '--> command not found')
import requests as r
import json
TOKEN = ''
# Executando requisição GET
resposta = r.get("https://api.codenation.dev/v1/challenge/dev-ps/generate-data?token="+TOKEN)
with open('answer.json', 'w') as arquivo:# Abrindo/Criando o arquivo para escrita (w)
retorno_json = resposta.json() # Pegando objeto JSON convertido em mapa
retorno_text = resposta.text # Pegando o texto
arquivo.write(retorno_text) # Escrevendo o arquivo
print(retorno_json)
ARQUIVO = 'answer.json'
multipart_form_data = {
'answer': (ARQUIVO, open(ARQUIVO, 'rb')),
}
resp = r.post(URL_POST+TOKEN, files=multipart_form_data)
print(resp.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment