Python reverse cipher

In this tutorial , I’ll tell you about reverse cipher encryption technique using python. Its our first cryptography tutorial using python programming.


Python programming tutorial


Cipher: an algorithm which is used to perform encryption or decryption


Reverse Cipher

Reverse cipher is technique to encrypt a text in reverse order. After reverse cipher encryption “Tech8six” text will be “xis8hcet”.


Check the example code below to understand reverse cipher



Explanation of Above Example

text = “Welcome to Tech8six” : assign a string to text  variable which we want to reverse.

encrypt = ”: its a simple variable, where our program will store reverse string

t = len(text) – 1: len() is function returns the length of the string,


We use -1 because in line six you can see text[t], the list index number starts from zero. check the code below to understand


while t >=0 : while loop with condition.

encrypt = encrypt + text[t] : It will store string in reverse order, until condition will be false

t = t-1 : This line is working as a decrement operator

print(encrypt):  This is print function to print output.



Example #2

In this example we will make modify our above code using input() function. With the help of input function a user can input a text from keyboard .


Note: If you want to get back your original text simply run again this code and enter your reverse text.