Created
August 23, 2016 16:02
-
-
Save drkpkg/014340705ad444d43195136baae7591c to your computer and use it in GitHub Desktop.
Cifrado cesar, bastante viejo supongo :P
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/python2 | |
import sys | |
def main(argv): | |
if (len(sys.argv) != 2): | |
sys.exit('Uso: caesar.py <entero>') | |
plaintext = list(raw_input('Mensage: ')) | |
alphabet = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') | |
k = int(sys.argv[1]) | |
cipher = '' | |
for c in plaintext: | |
if c in alphabet: | |
cipher += alphabet[(alphabet.index(c)+k)%(len(alphabet))] | |
print 'El mensaje encriptado es: ' + cipher | |
if __name__ == "__main__": | |
main(sys.argv[1:]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment