Created
July 6, 2015 19:29
-
-
Save jh00nbr/42ca35645d2176eb6844 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#Exemplo encrypt e decrypt by jh00n - Cifra de Cesar | |
import sys | |
def encrypt(mensagem): | |
cifra = '' | |
mensagem = mensagem.lower() | |
for letras in mensagem: | |
if letras in alfabeto: | |
x = alfabeto.find(letras) + chave | |
if x >= total: | |
x -= total | |
cifra += alfabeto[x] | |
return cifra | |
def decrypt(mensagem): | |
cifra = '' | |
mensagem = mensagem.lower() | |
for letras in mensagem: | |
if letras in alfabeto: | |
x = alfabeto.find(letras) - chave | |
cifra += alfabeto[x] | |
return cifra | |
if(len(sys.argv) < 4): | |
print "[+] Modo de uso: ./cifra.py <chave> <mensagem> <--encrypt>" | |
print "[+] Exemplo: ./cifra.py 3 aka --encrypt" | |
else: | |
alfabeto = 'abcdefghijklmnopqrstuvwxyz' | |
total = 26 | |
chave = int(sys.argv[1]) | |
msg = str(sys.argv[2]) | |
if "--encrypt" in sys.argv[3]: | |
print "[+] Mensagem: " + encrypt(msg) | |
elif "--decrypt" in sys.argv[3]: | |
print "[+] Mensagem: " + decrypt(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment