Skip to content

Instantly share code, notes, and snippets.

/.py

Created July 16, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9b880891a2a4a3c2528d9dff34b56467 to your computer and use it in GitHub Desktop.
Save anonymous/9b880891a2a4a3c2528d9dff34b56467 to your computer and use it in GitHub Desktop.
import sys
if len(sys.argv) != 2:
print("Error")
exit(1)
key = int(sys.argv[1])
text = input("plaintext: ")
buffer = ""
for s in text:
if s.islower():
buffer += chr((ord(s) + key - 97) % 26 + 97)
elif s.isupper():
buffer += chr((ord(s) + key - 65) % 26 + 65)
else:
buffer += s
print(buffer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment