Sunteți pe pagina 1din 16

Department of Electrical Engineering

HITEC University Taxila

Secure Communication of Voice


by Symmetric Encryption

Project Supervisor:
Group Members: MS Sehrish Mehmood
Nisar Ahmed Rana
Sheikh M Arshad
Ghazal Arshad
Maria Minhas
Hira Batool Rizvi Dated: Wednesday, February 10, 2010
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Page | 2

I dedicate this project to my dearest


friend Sheikh M Arshad.
Nisar Ahmed Rana

Dedicated to my sincere friend Nisar


Ahmed Rana.
Sheikh M Arshad

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Transmittal Message Page | 3

We have made our best efforts to make this project


report to come up with your standards. We used best
sources of knowledge up to standard level. We may have
many shortcomings in its design and layout. But if any
mistake takes place while making the report we hope
that you will ignore it and you will not consider it as a
major mistake and we expect courtesy from your side.

Thank you,

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Acknowledgement
Page | 4
First of all, we pay our thanks to almighty Allah, the most Merciful
and Beneficial, who is the entire source of aft knowledge and
wisdom. We have faced a lot of difficulties during this period of
developing project report. But Allah gave us a lot of courage and our
teachers encouraged us to do this. We offer thanks from the deepest
core of our heart to the Holy Prophet “Hazrat Muhammad” (Peace be
upon him) who is, forever a torch of guidance and knowledge for
humanity as a whole.
No words are sufficient to express our gratitude to our loving
parents for their exemplary patience, understanding and
cooperation during the preparation of this book.
We deeply express our sincere thanks to our Head of Department
Mr. Jamil Ahmed for his cooperation throughout the project work
and providing in with necessary facilities.
In completion of this project, we depend on expert input from our
project adviser, “MS Sehrish Mehmood” who guided us in each step
to make our project a better one.
We would like to thank our friend Talha Naveed, Muhammad Yasir February 10, 2010

and Kashif Hanif for his sincere help.


In addition we would like to thank our all those friends who helped
us in any form during the project completion and report writing.
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Table of Contents
Page | 5
Title 1

Dedication 2

Transmittal Message 3

Acknowledgement 4

1 Executive Summary 7

2 Introduction 8

2.1 Background 8

2.2 Scope 8

3 Procedure 9

3.1 Functions Used in Cryptosystem 9

3.2 Wavread 9

3.2.1 Syntax 9

3.2.1 Description 9

3.3 Input 10

3.3.1 Syntax 10

3.3.2 Description 10 February 10, 2010

3.4 Sound 10

3.4.1 Syntax 10

3.4.2 Description 10

3.5 Size 10

3.5.1 Syntax 10
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

3.5.2 Description 11

3.6 Zeros 11

3.6.1 Syntax 11
Page | 6
3.6.2 Description 11

3.7 For Loop 11

3.7.1 Syntax 11

3.7.2 Description 11

3.7.3 General Expression 12

4 Types of Cryptosystem 13

4.1 Digital Encryption Standard (DES) 13

4.2 International Data Encryption Algorithm (IDEA) 13

4.3 RC4 13

4.4 UNIX Crypt 13

4.5 RSA 13

4.6 Diffie Hellman 13

4.7 PGP 14

5 Programming Code for Cryptosystem 15

6 Conclusion 16

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Executive Summary
Page | 7
Cryptography is science of preparing coded or protected communications intended to be
intelligible only to the person possessing a key. The term Cryptography (Greek kryptos,
“secret”; graphos, “writing”) refers both to the process or skill of communicating in or
deciphering secret writings (codes) and to the use of codes to convert computerized data so
that only a specific recipient will be able to read it using a key.

In its broadest sense, cryptography includes the use of concealed messages, ciphers, and codes.
Concealed messages, such as those hidden in otherwise innocent text and those written in
invisible ink, depend for their success on being unsuspected. Once they are discovered, they
frequently are easy to decipher. Codes, in which predetermined words, numbers, or symbols
represent words and phrases, are usually impossible to read without the key codebook.
Cryptography also includes the use of computerized encryption to protect transmissions of data
and messages.

Cryptography is important for more than just privacy, however. Cryptography protects the
world’s banking systems as well. Many banks and other financial institutions conduct their
business over open networks, such as the Internet. Without the ability to protect bank
transactions and communications, criminals could interfere with the transactions and steal
money without a trace.

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Introduction
Page | 8
Our project is sound cryptography (Sound Encryption & Decryption). The user will give an input sound
and encryption factor. The sound will be converted to an encrypted sound file. This sound is not
understandable by any one. When the receiver will receive the encrypted file he will decrypt it and enter
the decryption factor so he will get the original file.

There are two kinds of cryptosystems.

1. Symmetric cryptosystem
2. A symmetric cryptosystem

Symmetric cryptosystems use the same key (a secret key) to encrypt and decrypt a message, and
asymmetric cryptosystems use one key (the public key) to encrypt a message and a different key (the
private key) to decrypt it, or vice versa.

Background
We are assigned to make a project of Signal & System course using MAYLAB. We have chosen to design
a cryptosystem. This cryptosystem will work on sound files whoever it can be used as a cryptosystem for
other type of data. This is very useful software which can be used for secret data transmission.

Scope
This cryptosystem has a wide range of application. We can use it for transmission of secret sound files. It
can be used for military purposes. All the banks and big companies can use data encryption. It can be
used to encrypt music files or videos. A slightly changed form of cryptosystem can be used in software
and online file transfer.

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Procedure
Page | 9
We have used a simple procedure for our cryptosystem due to limitation of our knowledge of the
subject. We have used “wavread()” command which input the windows *.wav sound file. Then the
software demands the encryption factor. The original sound is then encrypted into a sound which
contain one bit of original sound and n bits (n is encryption factor) of the carrier sound. Then it asks for
the decryption factor and save the sound data one bit after n bits into a file which is the reproduced
original sound.

Today a large number of cryptosystem are available. Following is a list of popular cryptosystem.

Functions used in Cryptosystem:

Wavread:
This function read Microsoft WAVE (.wav) sound file and save the data in matrix mxn form. In case of
mono sound the matrix will be 1xn and for stereo sound the matrix will be 2xn.

Syntax:
1. y = wavread(filename)
2. [y, Fs, nbits] = wavread(filename)
3. [...] = wavread(filename, N)
4. [...] = wavread(filename,[N1 N2])
5. y = wavread(filename, fmt)

Description:
 y = wavread(filename) loads a WAVE file specified by filename, returning the sampled data in y.
The filename input is a string enclosed in single quotes. The .wav extension is appended if no
extension is given.
 [y, Fs, nbits] = wavread(filename) returns the sample rate (Fs) in Hertz and the number of bits
per sample (nbits) used to encode the data in the file.
February 10, 2010

 [...] = wavread(filename, N) returns only the first N samples from each channel in the file.
 [...] = wavread(filename,[N1 N2]) returns only samples N1 through N2 from each channel in the
file.
 y = wavread(filename, fmt) specifies the data type format of y used to represent samples read
from the file. fmt can be either of the following values.
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Input:
Input function request user input in command window.
Page | 10
Syntax:
1. user_entry = input('prompt')
2. user_entry = input('prompt', 's')

Description:
The response to the input prompt can be any MATLAB expression, which is evaluated using the variables
in the current workspace.

 user_entry = input('prompt') displays prompt as a prompt on the screen, waits for input from
the keyboard, and returns the value entered in user_entry.
 user_entry = input('prompt', 's') returns the entered string as a text variable rather than as a
variable name or numerical value.

Sound:
This function converts vector into sound file.

Syntax:
1. sound(y,Fs)
2. sound(y)
3. sound(y,Fs,bits)

Description:
Sound(y,Fs) sends the signal in vector y (with sample frequency Fs) to the speaker on PC and most UNIX
platforms. Values in y are assumed to be in the range. Values outside that range are clipped. Stereo
sound is played on platforms that support it when y is an n-by-2 matrix. The values in column 1 are
assigned to the left channel, and those in column 2 to the right.

 Sound(y) plays the sound at the default sample rate or 8192 Hz.
 Sound(y,Fs,bits) plays the sound using bits number of bits/sample, if possible. Most platforms
February 10, 2010

support bits = 8 or bits = 16.

Size:
This function gives us dimension of array.

Syntax:
1. d = size(X)
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

2. [m,n] = size(X)
3. m = size(X,dim)
4. [d1,d2,d3,...,dn] = size(X),

Description:
d = size(X) returns the sizes of each dimension of array X in a vector d with ndims(X) elements. If X is a Page | 11
scalar, which MATLAB regards as a 1-by-1 array, size(X) returns the vector [1 1].

[m,n] = size(X) returns the size of matrix X in separate variables m and n.

m = size(X,dim) returns the size of the dimension of X specified by scalar dim.

[d1,d2,d3,...,dn] = size(X), for n > 1, returns the sizes of the dimensions of the array X in the variables
d1,d2,d3,...,dn, provided the number of output arguments n equals ndims(X). If n does not equal
ndims(X), the following exceptions hold:

Zeros:
This function creates an array of all zeros.

Syntax:
1. B = zeros(n)
2. B = zeros(m,n)
3. B= zeros([m n])
4. B = zeros(m,n,p,...)
5. B= zeros([m n p ...])
6. B = zeros(size(A))
7. zeros(m, n,...,classname)
8. zeros([m,n,...],classname)

Description:
 B = zeros(n) returns an n-by-n matrix of zeros. An error message appears if n is not a scalar.
 B = zeros(m,n) or B = zeros([m n]) returns an m-by-n matrix of zeros.
 B = zeros(m,n,p,...) or B = zeros([m n p ...]) returns an m-by-n-by-p-by-... array of zeros.
 B = zeros(size(A)) returns an array the same size as A consisting of all zeros. February 10, 2010

For Loop:
For loop executes a block of code for specified number of times.

Syntex:
1. for x=initval:endval, statements, end
2. for x=initval:stepval:endval, statements, end
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Description:
 for x=initval:endval, statements, end repeatedly executes one or more MATLAB statements in a
loop. Loop counter variable x is initialized to value initval at the start of the first pass through
the loop, and automatically increments by 1 each time through the loop. The program makes
repeated passes through statements until either x has incremented to the value endval, or
Page | 12
MATLAB encounters a break, or return instruction, thus forcing an immediately exit of the loop.
 for x=initval:stepval:endval, statements, end is the same as the above syntax, except that loop
counter x is incremented (or decremented when stepval is negative) by the value stepval on
each iteration through the loop. The value stepval must be a real number or can also be a call to
a function that returns a real number.

General Expression:
for variable = initval:endval statement

...

statement

end

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Types of Cryptosystem:
Page | 13
There are many types of cryptosystems available. Some of the most popular cryptosystems are given
below with brief description.

Digital Encryption Standard (DES):


The Digital Encryption Standard was developed by IBM and the National Security Agency (NSA) of the
USA in the 50s. DES uses a key of only 56 bits, and thus it is too weak and easy to be broken with today
technology.

International Data Encryption Algorithm (IDEA):


International Data Encryption Algorithm (IDEA) is a cryptosystem developed by X. Lai and J. Massey in
1991 to replace the DES standard. It is a symmetric (same key for encryption and decryption) block
cipher, operating on 8 bytes at a time, just like DES, but with a key of 128 bits.

RC4
A cipher invented by Ron Rivets, a proprietary system by RSADSI, is used in a number of commercial
systems like Lotus Notes and secure Netscape.

UNIX Crypt:
Many UNIX systems come supplied with an encryption system called crypt. This routine should never be
used for encrypting anything because there is a program on the net for producing the decrypted text
and the key.

RSA:
A cipher/algorithm based on the concept of a trapdoor function, which is easily calculated, but whose
inverse is extremely difficult to calculate. The RSA algorithm is named after Ron Rivets, Adi Shamir and
February 10, 2010

Len Adelman, who invented it in 1977. The RSA algorithm can be used for both public key encryption
and digital signatures. Its security is based on the difficulty of factoring large integers.

Diffie Hellman:
Diffie-Hellman is the first published the public key cryptographic algorithm which allows two users to
exchange a secret key over an insecure medium without any prior secrets. It has two system parameters
p and g. They are both public and may be used by all the users in a system. Parameter p is a prime
MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

number and parameter g is an integer less than p, with the following property: for every number n
between 1 and p-1 inclusive, there is a power k of g such that n = gk mod p.

PGP:
PGP is public key system for encrypting electronic mail using the RSA public key cipher. It encrypts the Page | 14
message using the IDEA cipher with a randomly generated key. It then encrypts the key using the
recipient’s public key. When the recipient receives the message, PGP uses his private RSA key to decrypt
the IDEA key and then uses that IDEA key to decrypt the message.

We have used a simple symmetric type cryptosystem for our software. We can change it with a little
modification into an asymmetric cryptosystem.

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Programming Code for cryptosystem


Page | 15
function encrypt(a,s)
a=wavread('keysound.wav');
sound(a,8000)
en=input('Enter the amount of distortion to Encrypt:')
a1=a';
[y,u]=size(a1)
c=wavread('add.wav');
c1=c';
c2=c1(1:u*en);
n=1
for(m=1:u)
c2(1,n)=a1(1,m);
n=n+en;
end
c3=c2';
sound(c3,8000);
o=1;
w=zeros(1,u);
dec=input('Enter the amount of distortion to Decrypt:')
for(m=1:u)
w(1,m)=c2(1,o);
o=o+dec;
end
w1=w';
sound(w1,8000)
end

February 10, 2010


MATLAB A PROJECT REPORT ON CRYPTOSYSTEM (ENCRYPTION & DECRYPTION)

Conclusion
Page | 16
We have learnt from this project that how to encrypt a sound file. Since this encryption phenomenon
has a wide range of application so we can encrypt sound files for these applications. We have also learnt
that how to decrypt a encrypted file. When we shall decrypt a sound file with the same factor we got
the original sound. We have also learnt to decrypt a sound file by two methods which are symmetric and
asymmetric. In symmetric we use the same decryption factor as we use to encrypt that sound file. While
on the other hand we use the different decryption factor.

February 10, 2010

S-ar putea să vă placă și