Algorithm of Reverse Cipher
Reverse Cipher uses a pattern of reversing the string of plaintext to convert as ciphertext
The algorithm of reverse cipher holds the following features:
- Reverse Cipher uses a pattern of reversing the string of plaintext to convert as ciphertext;
- The process of encryption and decryption is the same;
- To decrypt the ciphertext, we need to reverse the ciphertext to get the plaintext.
Drawback
The major drawback of a reverse cipher is that it is very weak.
message = 'This is a program to explain reverse cipher'
translated = '' # ciphertext is stored in this variable
i = len(message) - 1
while i >= 0:
translated = translated + message[i]
i = i - 1
print("The plaintext is.: {}".format(message.lower()))
print("The ciphertext is: {}".format(translated.upper()))
Output
The plaintext is.: this is a program to explain reverse cipher
The ciphertext is: REHPIC ESREVER NIALPXE OT MARGORP A SI SIHT
Explanation
The plaintext is stored in the variable message and the translated variable is used to store the ciphertext created.
The length of the plaintext is calculated using for loop and with help of index number. The characters are stored in the ciphertext variable translated which is printed in the last line.
Adapted by: tutorialspoint