Created
February 25, 2019 06:54
-
-
Save fadil703/c609da8b1821ab38ba1896c7f476cb14 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
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