Creating a Reverse Cipher in Python Cryptography
For this Cipher blog, we build on a simple plaintext to cipher
function creating a function named reverseCipher that accepts
one parameter: plaintext and get plaintext as a
human readable input from user by using input
method . We can then call our function and pass the plaintext into it and
print out the return ciphertext. Our
method modifies the plaintext so that the ciphertext is the
complete reverse:
#!/usr/bin/python import time def reverseCipher(plaintext): ciphertext = '' i = len(plaintext) - 1 while i >=0: ciphertext = ciphertext + plaintext[i] i = i - 1 return ciphertext plaintext = input('Enter your plaintext for encoding : ') ciphertext = reverseCipher(plaintext) print(ciphertext)
This code should produce the following result:
Read also - Hashing Cryptography 101