Skip to content

Instantly share code, notes, and snippets.

@fadil703
Created February 25, 2019 06:54
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 fadil703/c609da8b1821ab38ba1896c7f476cb14 to your computer and use it in GitHub Desktop.
Save fadil703/c609da8b1821ab38ba1896c7f476cb14 to your computer and use it in GitHub Desktop.
def main():
myMessage = input('Text to cipher: ').upper()
myKey = int(input('rail fence key: '))
ciphertext = transpoMessage(myKey, myMessage)
print(ciphertext)
def transpoMessage(key, plaintext):
ciphertext = [''] * key
for col in range(key):
pointer = col
while pointer < len(plaintext):
ciphertext[col] += plaintext[pointer]
pointer += key
return ''.join(ciphertext)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment