17
Matlab Project proposal: Our proposed project’s elaboration is as under Project title: Encryption and Decryption of Wave(sound) File in Image Formats Instructor: Sir Ali Ajwad Group detail: Sr no. Name Registeration no. 1 M SAIF UL ISLAM SP13-BCE-031 2 HABAB NISAR SP13-BCE-016 3 BILAL RAFIQUE SP13-BCE-010 4 HASEEB RAZA SP13-BCE-018

Encryption & Decryption of Sound in image format on Matlab

Embed Size (px)

Citation preview

Page 1: Encryption & Decryption of Sound in image format on Matlab

Matlab

Project proposal: Our proposed project’s elaboration is as under

Project title:

Encryption and Decryption of Wave(sound) File in

Image Formats

Instructor:

Sir Ali Ajwad

Group detail:

Sr no. Name Registeration no.

1 M SAIF UL ISLAM

SP13-BCE-031

2 HABAB NISAR

SP13-BCE-016

3 BILAL RAFIQUE

SP13-BCE-010

4 HASEEB RAZA SP13-BCE-018

Page 2: Encryption & Decryption of Sound in image format on Matlab

^

1 Encryption & Decryption of Sound

Contents Dedication: ................................................................................................................................................... 2

Acknowledgement: .................................................................................................................................. 3

Project in Brief: ............................................................................................................................................. 4

Abstract: ....................................................................................................................................................... 5

1. Introduction: ......................................................................................................................................... 6

1.1 Wave bitstream format .................................................................................................................... 6

1.2 Image Formats and Image Compression ......................................................................................... 7

2. Encryption ............................................................................................................................................. 8

2.1. Obtaining data of wave file in column matrix ..................................................................................... 8

2.2 Converting column matrix into M x N matrix. ................................................................................ 9

2.3 Converting matrix into Image File. ................................................................................................ 10

3. Decryption of wave from image ........................................................................................................ 11

3.1 Data type conversion ........................................................................................................................... 11

3.2 Algorithm to convert image matrix into column matrix and hence .wav. ......................................... 12

3.3 Audio Recorder: .................................................................................................................................... 12

4. Graphical use Interface(GUI): ............................................................................................................ 12

4.1 Creating a MATLAB GUI ....................................................................................................................... 13

4.2 Explanation: .......................................................................................................................................... 13

4.3. Final output: ........................................................................................................................................ 15

5. Deploy tool: .................................................................................................................................... 15

6. Uses: .................................................................................................................................................... 16

7. Bibliography: ...................................................................................................................................... 16

Page 3: Encryption & Decryption of Sound in image format on Matlab

^

2 Encryption & Decryption of Sound

Dedication:

WE DEDICATE THIS PROJECT TO OUR PARENTS AND TO ALL OF

OUR TEACHERS WHO EDUCATED US IN WHOLE AGE OF

EDUCATION FROM SCHOOL TO UNIVERSITY.

Page 4: Encryption & Decryption of Sound in image format on Matlab

^

3 Encryption & Decryption of Sound

Acknowledgement:

All praise to Almighty Allah, the most merciful and Compassionate, who enabled us to

complete this Project. We express our gratitude to our kind supervisor Sir Ali Ajwad who

is behind the idea of this project. We express to our gratitude to our kind Theory

instructor Sir Ahsen Malik who kept our morale high by his suggestions and appreciation.

He was available to us whenever and for whatever we consulted him. To our class fellows

and friends, we always remember their cooperation with us. They helped us in our project

wherever we needed, especially our fellow Mr. Sohaib , Mr. Naqqash and Miss Saima for

providing their help. At last but not the least; we would like to acknowledge the support

of our family members. We would like to admit that we owe all our achievement’s to our

truly, sincere and most loving parents, brothers and sisters who mean the most to us, and

whose prayers are a source of determination for us.

Page 5: Encryption & Decryption of Sound in image format on Matlab

^

4 Encryption & Decryption of Sound

Project in Brief:

Project Title: Encryption and Decryption of Wave File in Image Formats.

Undertaken By:

Bilal Rafique ----- Sp13-BCE-010 M Saif Ul Islam -- Sp13-BCE-031 Habab Nisar ---- Sp13-BCE-014 Haseeb Raza ---- Sp13-BCE-015

Course: Signals & Systems

Instructors:

Lab: Sir Ali Ajwad Theory: Sir Ahsen Malik

Tool Used: Matlab R2014

Operating System: Windows 8.1

Dated: 20-Dec-2014

Page 6: Encryption & Decryption of Sound in image format on Matlab

^

5 Encryption & Decryption of Sound

Abstract:

We will be elaborating the method of encrypting wave files in popular image formats like JPEG, TIF and PNG along with retrieving them from these image files. MATLAB software is used to perform matrix manipulation to encrypt and decrypt sound files into and from image files. This method is not only a stenographic means but also a data compression technique. Steganography (a rough Greek translation of the term Steganography is secret writing) has been used in various forms for 2500 years. Briefly stated, steganography is the term applied to any number of processes that will hide a message within an object, where the hidden message will not be apparent to an observer.

Page 7: Encryption & Decryption of Sound in image format on Matlab

^

6 Encryption & Decryption of Sound

1. Introduction:

This present work puts forth a novel method to encrypt ‘.wav’, which are basically sound files in image formats such as PNG, TIF and JPEG. The sound file is fetched and the values corresponding to the sample range is put in a column matrix which is then put in a two dimensional matrix having “double” as data-type. Using ‘imwrite’ function of MATLAB, this matrix defined in the class ‘double’ is put in a graphics file or image file. After encryption the data is retrieved from the image file and compared with the original wave file to show the variation in encrypted and decrypted data. This methodology can not only be used as stenographic means but possibly as a technique for data compression. The illustrated method for data encryption of sensitive user information can be used as a viable method to further secure cloud computing transactions.

Figure 1

1.1 Wave bitstream format

Waveform Audio File Format (WAVE) is an application of RIFF or Resource Interchange File Format which stores audio bit streams in “chunks”. WAVE encodes the sound in LPCM format i.e. Linear Pulse Code Modulation. Sound is basically a pressure wave or mechanical energy having pressure variance in an elastic medium. The variance propagates as compression and rarefaction wherein

Page 8: Encryption & Decryption of Sound in image format on Matlab

^

7 Encryption & Decryption of Sound

compression occurs when pressure is higher than the ambient pressure and rarefaction occurs when the pressure of the propagating wave is less than the ambient pressure. Exactly in the same manner a WAVE file just represents the sampled sound waves which happen to be above or below the equilibrium or ambient air pressure. The plot of wave file is shown in fig 1.

Figure 2

1.2 Image Formats and Image Compression

Digital image formats are means of storing digital images in either uncompressed (e.g. TIFF), compressed (e.g. JPEG) and vector formats. On rasterization an image is converted into a grid of pixels. Basically there are two types of image file compression algorithm- lossless and lossy. In lossless compression the entire digital data is preserved during compression thus preserving image quality. In lossy compressions, the digital data

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2

x 106

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4wav form of first 2000000 samples

Page 9: Encryption & Decryption of Sound in image format on Matlab

^

8 Encryption & Decryption of Sound

preservation takes place by compromising image quality . Here we will be discussing PNG, TIFF and JPEG formats and these are the very formats in which the wave file will be encrypted into.

MASTER IMAGE FORMATS

2. Encryption

2.1. Obtaining data of wave file in column matrix

We will be using “dil.wav” wave file as a example whose wave representation is

show above in fig 1. The sampling length of this tone is 2000000 samples.

Following is the MATLAB code which fetches the wave file using ‘wavread’

function. Amplitude values are obtained in the range of 0 and +1.

Page 10: Encryption & Decryption of Sound in image format on Matlab

^

9 Encryption & Decryption of Sound

Variable ‘D’ which holds first 2000000 samples. It is to be noted that the variable D is basically a column vector.

2.2 Converting column matrix into M x N matrix.

A ‘grayscale’ image of M by N pixels is represented in MATLAB as an M X N

matrix having “double” data type wherein each element of the matrix denotes a

pixel within an intensity of 0 and 1. It is to be noted that the variable D is a

column matrix with “double” type and intensity within 0 and 1. So to convert

variable D in an image format we have to transform D into a 1000 X 2000 matrix.

Figure 3 conversion from 1d to 2d

Page 11: Encryption & Decryption of Sound in image format on Matlab

^

10 Encryption & Decryption of Sound

Code to convert to convert matrix A into MxN is shown in fig.4

Figure 4

2.3 Converting matrix into Image File.

We convert matrix A into JPEG , PNG and TIF formats using MATLAB function called “imwrite”. Imwrite (A,’.../filename.xyz’); The above syntax stores matrix A in the file path mentioned. We also save column matrix D in a new wave file using “wavwrite” function.

How the wave file appears in JPEG format (this is a cropped image as the actual file is far bigger).also shown in fig.5

Figure 5

Page 12: Encryption & Decryption of Sound in image format on Matlab

^

11 Encryption & Decryption of Sound

3. Decryption of wave from image This method is just the opposite of encryption with minor variations. When the image is

created during encryption it is basically an MxN matrix with “double” data type,

however on fetching the same image back to MATLAB we get an MxN matrix with

datatype “uint8” i.e. unsigned integer of 8 bit.

Thus we need to first convert all elements of matrix obtained into double precision .

Decryption can be basically understood as a data mining method to fetch, audit and

understand the pattern of data stored in the encrypted file.

3.1 Data type conversion

“im2double” function of MATLAB takes an image as input and converts it into another

image or matrix having all elements with type double. As already stated, the image files

retrieved by MATLAB are in unsigned integer form and before they are put in column

matrix representing a WAVE file, it has to be converted into data type of double precision.

Page 13: Encryption & Decryption of Sound in image format on Matlab

^

12 Encryption & Decryption of Sound

3.2 Algorithm to convert image matrix into column matrix

and hence .wav. “wavwrite ( X, FS, ‘.../filename.wav’);”

The above function is used to save X column vector in the given ‘filename’ () with a desired

frequency ‘FS’. The column vector X is obtained by converting image matrix of double

precision into column matrix. The method is explained in the following programming code

of MATLAB.

3.3 Audio Recorder: Matlab build in function recorder = audiorecorder(Fs,nBits,nChannels) which allows us to to record the

sound for specific time is used is to record the audio message of user for 50 seconds.

4. Graphical use Interface(GUI):

In computing, a graphical user interface (GUI, sometimes pronounced "gooey" (or "gee-

you-eye")) is a type of interface that allowsusers to interact with electronic

devices through graphical icons and visual indicators such as secondary notation, as

opposed to text-based interfaces, typed command labels or text navigation. GUIs were

introduced in reaction to the perceived steep learning curve ofcommand-line

interfaces (CLIs), which require commands to be typed on the keyboard.

The actions in a GUI are usually performed through direct manipulation of the graphical

elements. In addition to computers, GUIs can be found in hand-held devices such

as MP3 players, portable media players, gaming devices and smaller household, office

and industry equipment.

Page 14: Encryption & Decryption of Sound in image format on Matlab

^

13 Encryption & Decryption of Sound

4.1 Creating a MATLAB GUI

GUIs (also known as graphical user interfaces or UIs) provide point-and-click control of

software applications, eliminating the need to learn a language or type commands in

order to run the application.

MATLAB apps are self-contained MATLAB programs with GUI front ends that automate a

task or calculation. The GUI typically contains controls such as menus, toolbars, buttons,

and sliders. Many MATLAB products, such as Curve Fitting Toolbox, Signal Processing

Toolbox, and Control System Toolbox, include apps with custom user interfaces. You can

also create your own custom apps, including their corresponding UIs, for others to use.

GUIDE (graphical user interface design environment) provides tools for designing user

interfaces for custom apps. Using the GUIDE Layout Editor, you can graphically design

your UI. GUIDE then automatically generates the MATLAB code for constructing the UI,

which you can modify to program the behavior of your app.

4.2 Explanation:

Figure 6 shows GUI model created with GUIde command here we put three axes 2 for

showing wave of encrypted and decrypted signal. And 3rd for displaying the logo of

Comsats. There are static text fields for displaying the text i.e group member names. We

add 8 push buttons in our GUI as shown in fig. 6 whose operation is written on each

button. We use build in function uiget file to select sound file from computer. We can

make tags for component placed. Then the function of each component can be assigned

with the help of its tag. After making the model we press the play button in menu bar of

window then this will create the code of GUI layout. Code contains different functions

each button’s functionality can be controlled by its function. We can use handles of every

function along with component tag to shift between different functions. Each component

function is loaded with its code and the final output GUI is shown in figure 7.

Page 15: Encryption & Decryption of Sound in image format on Matlab

^

14 Encryption & Decryption of Sound

Figure 6 GUI CREATION

Page 16: Encryption & Decryption of Sound in image format on Matlab

^

15 Encryption & Decryption of Sound

4.3. Final output:

Figure 7 GUI FINAL OUTPUT

5. Deploy tool:

We have used the deploy tool command of matlab to make the .exe file of our application,

so that every one can use this application however his/her computer has no matlab

software.

Page 17: Encryption & Decryption of Sound in image format on Matlab

^

16 Encryption & Decryption of Sound

6. Uses: There are very vast applications/uses of encryption and decryption for which this app is helpful few of

them are given below:

Secure data transfer.

Military intelligence purposes.

Safe communication.

7. Bibliography:

http://www.cheers4all.com/2012/07/secure-communication-by-encryption-and-decryption-

matlab-code/

http://www.techopedia.com/definition/1773/decryption http://en.wikipedia.org/wiki/WAV arxiv.org/pdf/1307.6711