Created
May 29, 2015 19:00
-
-
Save VFS/ecc3252a3963f5d7a6be 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/env python3 | |
import string | |
p = '' | |
k = '' | |
c = '' | |
def cifrar(p,k): | |
if(p == ' '): | |
return ' ' | |
else: | |
cif = (((ord(p)-97)+(ord(k)-97))%26) | |
return string.ascii_lowercase[cif] | |
def decifrar(c,k): | |
if(c == ' '): | |
return ' ' | |
else: | |
decif = (((ord(c)-97)-(ord(k)-97)+26)%26) | |
return string.ascii_lowercase[decif] | |
for i in range(len(p)): | |
print(p[i]+' -> '+k[i]+' = '+cifrar(p[i],k[i])) | |
print('\n\n\n') | |
for i in range(len(p)): | |
print(cifrar(p[i],k[i]),end='') | |
#for i in range(len(p)): | |
# print(c[i]+' -> '+k[i]+' = '+decifrar(c[i],k[i])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment