Created
December 17, 2015 03:21
-
-
Save nuit/b2217df92d994fcec8ca to your computer and use it in GitHub Desktop.
Cifra de Cesar - cifrar <-> quebrar
This file contains hidden or 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
import sys | |
a=list('abcdefghijklmnopqrstuvwxyz') | |
A=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') | |
s=raw_input('texto: ') | |
def rot(k): | |
for j in s: | |
if j==' ': | |
sys.stdout.write(' ') | |
if j.isupper(): | |
for i in xrange(0,26): | |
if A[i]==j: | |
x=i+k | |
y=x%26 | |
sys.stdout.write(A[y]) | |
else: | |
for i in xrange(0,26): | |
if a[i]==j: | |
x=i+k | |
y=x%26 | |
sys.stdout.write(a[y]) | |
def rotall(s): | |
for k in xrange(26): | |
rot(k) | |
print ' ['+str(k)+']' | |
rotall(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment