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.

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
Sigueme en Twitter : @Sankosk
Estos nuevos staff no tienen puta idea XD