CIT PYTHON COHORT THREE
  • CIT Python Cloud Software Engineering
  • week one
    • What is Python
    • Python Syntax
    • variables
    • Numbers / Integers
  • week Two
    • Control Flow Statements
      • If Statements
      • For Loops
      • While Loops
      • Break and Continue Statements
    • Operators
      • Assignment Operators
      • Arithmetic Operators
      • Comparison Operators
      • Logical Operators
      • Relational Operators
      • Bitwise Operators
      • Identity Operators
      • Membership Operators
    • Data Types
      • Strings
      • Numbers
      • Booleans
      • Lists
      • Dictionaries
      • Tuples
      • Sets
  • Week 3
    • Functions
      • Function Arguments
      • Python Recursion
      • Python Anonymous/Lambda Function
    • Object Oriented Programming
      • Classes
      • Inheritance
      • Polymorphism
      • Abstraction
      • Encapsulation
    • Python Modules
      • Python Packages
      • Python Built-in Modules
      • Python Standard Library
      • Python Third Party Modules
    • Python Exceptions
      • Python Try Except
      • Python Raise
      • Python Assert
      • Python User-defined Exceptions
  • Week 4
    • Python File Handling
  • Week6
    • Data Structures and Algorithms
      • DSA Introduction
      • What is an Algorithm?
      • Data Structures and Types
      • Stack
      • Queue
      • Linked List
      • Bubble Sort Algorithm
      • Selection Sort Algorithm
      • Insertion Sort Algorithm
      • Merge Sort Algorithm
      • Quick Sort Algorithm
  • Week8
    • Cryptography
      • Reverse Cipher
      • Caesar Cipher
      • Hash Functions
        • Applications of Hash Functions
        • Examples of Hash Functions
  • Assignments and Solutions
    • Loops
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Week8
  2. Cryptography

Reverse Cipher

Reverse Cipher is a simple cipher that reverses the order of the characters in the message. It is a weak cipher because it is very easy to crack. It is also known as the reverse cipher.

PreviousCryptographyNextCaesar Cipher

Last updated 2 years ago

Was this helpful?

Algorithm of Reverse Cipher

The algorithm of reverse cipher holds the following features −

- Reverse Cipher uses a pattern of reversing the string of plain text to convert as cipher text.

- The process of encryption and decryption is same.

- To decrypt cipher text, the user simply needs to reverse the cipher text to get the plain text.
Reverse Cipher

Example

Consider an example where the statement This is program to explain reverse cipher is to be implemented with reverse cipher algorithm. The following python code uses the algorithm to obtain the output.

# Python program to illustrate Reverse Cipher Technique

def reverse(text):
    result = ""
    for i in range(len(text) - 1, -1, -1):
        result += text[i]
    return result

# plain text
text = "This is program to explain reverse cipher"

# calling the reverse function
s = reverse(text)

print("Plain Text : ", text)
print("Cipher: ", s)

When the above code is executed, it produces the following result −

Plain Text :  This is program to explain reverse cipher
Cipher:  repihc esrever ylniapxe ot margorp si sihT

Explaination

The above code uses the reverse function to reverse the string of plain text. The reverse function takes the string as an argument and returns the reversed string. The reversed string is stored in the variable s. The variable s is printed as the cipher text.

Assignment.

  1. Write a python program to implement reverse cipher algorithm using a while loop.

  2. Using lambda function, write a python program to implement reverse cipher algorithm.