Skip to content

Instantly share code, notes, and snippets.

@nuit
Created December 17, 2015 03:21
Show Gist options
  • Save nuit/b2217df92d994fcec8ca to your computer and use it in GitHub Desktop.
Save nuit/b2217df92d994fcec8ca to your computer and use it in GitHub Desktop.
Cifra de Cesar - cifrar <-> quebrar
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