You are on page 1of 6

Introduction

Python –The New Generation Language

Python is a widely used general-purpose, high level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It
was mainly developed for an emphasis on code readability, and its syntax allows
programmers to express concepts in fewer lines of code. Python is dynamically typed and
garbage-collected. It supports multiple programming paradigms, including procedural,
object-oriented, and functional programming. Python is often described as a "batteries
included" language due to its comprehensive standard library.

Features

• Interpreted

In Python there is no separate compilation and execution steps like C/C++. It directly run
the program from the source code. Internally, Python converts the source code into an
intermediate form called bytecodes which is then translated into native language of specific
computer to run it.

• Platform Independent

Python programs can be developed and executed on the multiple operating system platform.
Python can be used on Linux, Windows, Macintosh, Solaris and many more.

• Multi- Paradigm

Python is a multi-paradigm programming language. Object-oriented programming and


structured programming are fully supported, and many of its features support functional
programming and aspectoriented programming .

• Simple

Python is a very simple language. It is a very easy to learn as it is closer to English language.
In python more emphasis is on the solution to the problem rather than the syntax.

• Rich Library Support

Python standard library is very vast. It can help to do various things involving regular
expressions, documentation generation, unit testing, threading, databases, web browsers,
CGI, email, XML, HTML, WAV files, cryptography, GUI and many more.

• Free and Open Source

8
Firstly, Python is freely available. Secondly, it is open-source. This means that its source
code is available to the public. We can download it, change it, use it, and distribute it. This
is called FLOSS (Free/Libre and OpenSource Software). As the Python community, we’re
all headed toward one goal- an ever-bettering Python.

Encrypt and Decrypt message and image using python

Encryption is the act of encoding a message so that only the intended users can see it. We
encrypt data because we don’t want anyone to see or access it.
We will use the cryptography library to encrypt a file. The cryptography library uses a
symmetric algorithm to encrypt the file. In the symmetric algorithm, we use the same key to
encrypt and decrypt the file. The fernet module of the cryptography package has inbuilt
functions for the generation of the key, encryption of plain text into cipher text, and
decryption of cipher text into plain text using the encrypt() and decrypt() methods
respectively. The fernet module guarantees that data encrypted using it cannot be further
manipulated or read without the key.

Encryption
It is nothing but a simple process in which we convert our data or information into secret
code to prevent it from unauthorized access and keep it private and secure.
First, we will select an image, and then we will convert that image into a byte array due to
which the image data will be totally converted into numeric form, and then we can easily
apply the XOR operation to it. Now, whenever we will apply the XOR function on each
value of the byte array then the data will be changed due to which we will be unable to access
it. But we should remember one thing here our encryption key plays a very important role
without that key we can not decrypt our image. It acts as a password to decrypt it.
The below program depicts the basic approach to encryption:
# Assign values
data = 1281
key = 27

# Display values
print('Original Data:',
data) print('Key:', key)

9
# Encryption
data = data ^ key print('After
Encryption:', data)

# Decryption data = data ^ key


print('After Decryption:', data)

Output:

Original Data: 1281


Key: 27
After Encryption: 1306
After Decryption: 1281

Decryption
It is nothing but a process of converting our encrypted data into a readable form. Here
we will again apply the same XOR operation on an encrypted image to decrypt it. But always
remember that our encryption key and decryption key must be the same.
Executable Code for Decryption:

# try block to handle the exception


try:
# take path of image as a input

path = input(r'Enter path of Image : ')

# taking decryption key as input key =

int(input('Enter Key for encryption of Image : '))

# print path of image file and decryption key that we are using

10
Abstract

In this project we have created a Python programming Project named “Message and Image
Encryption and Decryption”. An Image Encryption Decryption is an image processing
application created in python with tkinter gui and OpenCv library.
In this application user can select an image and can encrypt that image to gray scale image
and can even decrpyt also.
The purpose of encryption is confidentiality concealing the content of the message by
translating it into a code.
Also after encrypting and decrypting user can also save the edited image anywhere in the
local system.
Also there is option to reset to the original image.

13
Objectives
The main objective of our project is to provide security of the message and image-based
data with the help of suitable key and protect the message and image from illegal copying
and distribution

14

You might also like