Saltar al contenido
Underc0de /foro

Cifrado solitario

Iniciado por Sanko, Febrero 13, 2014, 12:48:47 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Avatar de Sanko
Febrero 13, 2014, 12:48:47 PM Ultima modificación: Marzo 16, 2014, 08:53:41 PM por Expermicid

Código: python
import string
xAbc = string.ascii_lowercase + '-'

def solitario(texto, ristra, opt):
    nText = [xAbc.find(x) + 1 for x in texto.lower()]
    nRistra = [xAbc.find(x) + 1 for x in ristra.lower()]
   
    if opt == 1:
        print "".join([xAbc[x - 1].replace('-', ' ') for x in [(nText[x] + nRistra[x]) % 26 for x in range(len(texto))]])

    elif opt == 0:
        print "".join([xAbc[x - 1].replace('-', ' ') for x in [(nText[x] - nRistra[x]) % 26 for x in range(len(texto))]])
       
#encoded output -> oexwa khqtw
#decoded output -> donot usepc
WhatsApp Telegram
Sigueme en Twitter : @Sankosk
Estos nuevos staff no tienen puta idea XD

🔗 Temas relacionados

¿Te quedó una duda sobre Python?

Preguntala y te responde la comunidad (y el asistente Underc0de IA si nadie llega antes). Es gratis y tarda un minuto.

Ya tengo cuenta
Guardamos tu pregunta en este navegador: después de entrar la publicás con un clic.
Grupo de WhatsApp